Returning Display name from an ID - InfoPath Dev
in

InfoPath Dev

Returning Display name from an ID

Last post 04-07-2010 01:23 PM by DanRegalia. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-06-2010 10:00 AM

    Returning Display name from an ID

    Hey all, long time no see, hope all is well with you.

    I'm running into an odd situation.. I have a filtered list that displays text values, and saves the ID in a field.  I want to return the Display name field into another field i've setup.

    I followed these instructions that i found on a different site (See below the post).  

    I made a rule that says update a field with this value: 

    xdXDocument:GetDOM("vwFIMS_Sizes")/dfs:myFields/dfs:dataFields/d:vwFIMS_Sizes/@SizeName[@SizeID = number(.)]

    (I've also tried:  xdXDocument:GetDOM("vwFIMS_Sizes")/dfs:myFields/dfs:dataFields/d:vwFIMS_Sizes/@SizeName[xdXDocument:GetDOM("vwFIMS_Sizes")/dfs:myFields/dfs:dataFields/d:vwFIMS_Sizes/@SizeID = .]  )

     Now.. vsFIMS_Sizes is the Datasource that i'm pulling in from the database

    Field names are pretty self explanatory.  

    Now, the field returns back a number that makes no sense whatsoever (which is not an sizeID that is not a value in my filtered list). 

    Any insight you can give would be much appreciated.  

    ~Dan

     

     Here are the instructions i followed to get there:

    Add fields to the form:

       1. Add a combo box. This will contain the dynamic list of names to be used. Give this control a meaningful name, as it will be referenced by other fields on the form. I named mine "NameOfRequestor"
       2. Add two text boxes and make them read only. these will display the Phone and Email addresses. Since they are lookup values, I didn't want the user to change them. I named these fields "RequestorPhone" and "RequestorEmail".

    Add a data connection:

       1. Go to Data Sources and add a new connection to Receive Data.  
       2. Select SharePoint Library or List
       3. Enter the URL of the site you're receiving data from.
       4. Select the list / library.
       5. Specify the columns you want to include in your resultset (In my case, it was Full Name, Phone, and Email)
       6. You can optionally choose to save a copy of the downloaded results in the form template, so that it will contain a snapshot of list items that will be available when the form is filled out offline.
       7. Provide a name for the data connection (I named mine "Requestors") and click Finish.

           

    Click on Properties to Bind the Data Connection to the Combo Box.

       1. Under Llist box entries, select "Look up values from an external source"
       2. Select the data source you created above.
       3. In the "Entries" field, click the Browse button and drill down to MyFields-->dataFields-->(Your data connection). Click OK.
       4. The "Value" and "Display Name" fields will suggest a field to be used, If it is not the right one, browse to the correct fields. In my case it was @Full_Name.

    Set up a Rule to update other fields when this field is updated.

       1. In the Combo Box properties, click the "Rules" button. Add a new rule.
       2. Do not set a condition (this rule always applies).
       3. Add an action to update the RequestorPhone text box.
           

        * Action: "Set a field's value".  
        * Field: This part is a little tricky. You want to update the text box, so be sure the "Data source" is set to "Main". Drill down to the "RequestorPhone " field and click OK.
        * Value: Click the formula button.  
              o Click the Insert Field or Group button and select the Requestors Data source you added above.  
              o Drill down to the "MyFields-->dataFields-->Requestors" and select the field for "Business_Phone" (this is the name of the field in my SharePoint list).  
              o Click the Filter Data button.  
                    + Add a filter for when "Full_Name" "is equal to" and in the criteria field, click "Select Field or Group". In the "Main" data source, select the "NameOfRequestor" combo box.  
                    + Click OK.
                    + Click OK.  
              o The formula should read something like "@Business_Phone[@Full_Name = NameOfRequestor]".  
              o Which translates to "Show me the [Business Phone] value from my data set where the [Full Name] value matches whatever value is in the Combo Box [NameOfRequestor].
        * You're not done!

  • 04-07-2010 06:47 AM In reply to

    Re: Returning Display name from an ID

    Hi Dan and welcome back!

    Can you attach your XSN or a sample that shows the error? My hunch is that the "." in your xpath won't work because you are in a repeating structure, but I need to look at your form to ascertain.

    Patrick Halstead
    Project Manager at Qdabra
  • 04-07-2010 10:09 AM In reply to

    Re: Returning Display name from an ID

     What parts of the xsn do you want?  the datasource of the vwFIMS_Sizes or actual code behind the form?

     EDIT:
    Or if you shoot me a private message with your email address in it, i'll email you the entire xsn file.

  • 04-07-2010 01:23 PM In reply to

    Re: Returning Display name from an ID

     Patrick,

     You are correct, i am in a repeating section.  Does that mean i would have to use something like:  

    xdXDocument:GetDOM("vwFIMS_Sizes")/dfs:myFields/dfs:dataFields/d:vwFIMS_Sizes/@SizeName[xdXDocument:GetDOM("vwFIMS_Sizes")/dfs:myFields/dfs:dataFields/d:vwFIMS_Sizes/@SizeID = current()/number(.)] 

    Where i specify to use the current row's value?

     

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.