Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 ?

share|improve this question
add comment

4 Answers

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
share|improve this answer
add comment

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.

share|improve this answer
    
I'm gonna try workflow today.Thanks for advice. Have a good day. –  alicanbatur Jun 29 '12 at 5:46
add comment

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);
share|improve this answer
    
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
add comment

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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