I have a list with 3 columns in it.

Title, QType, Qtype_Text ..

Title is usual field. QType is a lookup field (it works). And Qtype_Text is a kind of singleline textbox. I want to get QType's display text to Qtype_Text. Coz QType cannot be used at other lists so I decided to take its text to a column at form. But here I cannot take the String Value.

If I use QType at formula, I get items' IDs. But I can't get the texts.

I tried this simple Xpath code:

@Title[@ID=QType] - > Dont Work.

And there's also something I couldn't remember, how can I get that text ?


In the Lookup column definition of the QType column you can specify that an additional column should be added, which displayes additional fields of the referenced value:

enter image description here

  • Hi, I get what you trying to say but its not my problem's solution :/ I just need names of lookup field at another field. Thanks for your advice – alicanbatur Jun 29 '12 at 5:48

Try this in an event receiver:

private void copyFromLookupToString(string fromLookup, string toField,      
SPItemEventProperties properties)
           if (properties.ListItem[fromLookup] != null)
               string LookupField = properties.ListItem[fromLookup].ToString();
               string[] LookupParts = LookupField.Split(new string[] { ";#" }, StringSplitOptions.None);
               string PopulateFieldWith = LookupParts[1];
               properties.ListItem[toField] = PopulateFieldWith;

Call it like this:

copyFromLookupToString(QType, QType_Text, properties);
  • Hi, Thanks. But I cannot use programmaning for now. Coz i dont have VS. I am trying to do it with sharepoint or infopath options. – alicanbatur Jun 29 '12 at 5:46

One more option here is to have a simple workflow which copies the selected lookup field value to the text field. The workflow can be triggered whenever the item is edited. But please check if you can use the option suggested by Matthias which seems to be more simple & clean solution.

  • I'm gonna try workflow today.Thanks for advice. Have a good day. – alicanbatur Jun 29 '12 at 5:46

I had a similar problem so for future reference this is how I resolved it.

Like you, I have cascading drop down lists that are populated using lookup data and I wanted to concatenate the displayed text from the first drop down list with the selected value in the second list for use in another field.

I added an xpath formula to the destination field that looks like the following:

concat(xdXDocument:GetDOM("GasRegion")/dfs:myFIelds/dfs:dataFields/d:SHarePointListItem_RW[d:ID = xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:FaultCity]/d:Title, " - ", ../my:FaultSuburb)

Kind of a mouthful but it's mostly just a way to identify the particular value from the lookup connection. In this case GasRegion is a connection used for as the source for the first drop down list. The formula is looking for a match of the ID value in the lookup data with the value selected in the drop down list. Having found a match, it outputs the Title which is the description field for the lookup.

In the situation you've outlined you would need to replace GasRegion with your data source connection. You could try the following formula:

xdXDocument:GetDOM("Replace with your lookup datasource")/dfs:myFIelds/dfs:dataFields/d:SharePointListItem_RW[d:ID = xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:QType]/d:Title
  • 2
    While not directly related I have used this to set a value of a lookup field based on Title, as opposed to ID inside of InfoPath 2010. Thought I would post it as a comment, here is the rule: xdXDocument:GetDOM("DF")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[d:Title = "AA"]/d:Title – Tom Aug 10 '15 at 9:50
  • QType (next article) and this comments are useful ! thanks – saber tabatabaee yazdi Oct 29 '16 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.