Hello again. Got sidetracked for a while and now I am back with this. Per some changes below, this was the only way I could correctly autopopulate job titles in the repeating table in my browser-enabled form. The one annoying behavior remaining is that with each row insert MY job title gets prepopulated (it then gets immediately overridden by the correct title based on the person entered in the control). I’ve tried to clear the job title at different points within the method, to no avail. Any ideas on how to overcome this? Appreciate your insight. To refresh your memory, I am invoking "getuserprofilebyname" from the "userprofileservice" web service.
My main data source now looks like this (same structure as before, some items differently named):
ContactSelector_Resources (repeating group)
gpContactSelector
Person (repeating group)
DisplayName
AccountId
AccountType
resource_title
(...)
Code:
public void InternalStartup()
{
EventManager.XmlEvents["/my:myFields/my:ContactSelector_Resources/my:gpContactSelector/my:Person"].Changed += new XmlChangedEventHandler(ContactSelector_Resources_gpContactSelector_Person_Changed);
}
(...)
public void ContactSelector_Resources_gpContactSelector_Person_Changed(object sender, XmlEventArgs e)
{
if (!e.Operation.Equals(XmlOperation.Delete))
{
XPathNavigator secondaryDS = DataSources["GetUserProfileByName"].CreateNavigator();
XPathNavigator secondaryRef = secondaryDS.SelectSingleNode("/dfs:myFields/dfs:queryFields/s0:GetUserProfileByName/s0:AccountName", NamespaceManager);
XPathNavigator mainDS = e.Site.CreateNavigator();
XPathNavigator mainRef = mainDS.SelectSingleNode("my:AccountId", NamespaceManager);
secondaryRef.SetValue(mainRef.Value);
DataSources["GetUserProfileByName"].QueryConnection.Execute();
secondaryRef = secondaryDS.SelectSingleNode(@"/dfs:myFields/dfs:dataFields/s0:GetUserProfileByNameResponse/s0:GetUserProfileByNameResult/s0:PropertyData[s0:Name = ""Title""]/s0:Values/s0:ValueData/s0:Value", NamespaceManager);
XPathNavigator jobtitle = mainDS.SelectSingleNode("../../my:resource_title", NamespaceManager);
if (secondaryRef != null)
{
jobtitle.SetValue(secondaryRef.Value);
}
else
{
jobtitle.SetValue(string.Empty);
}
}
}