cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tiddlyplatypus
Frequent Visitor

Lookup a record by ID

Hi All,

Have a relatively simple one that seems to be harder than I think it should be:

 

I've got a canvas app that accepts a "SurveyInstance" parameter, which I expect to match the unique identifier for my SurveyInstance CDS entity:

tiddlyplatypus_0-1634332189759.png

The general idea here is that I'd like to tie the survey instance to a specific employee and a specific survey.  If the survey instance is not provided, I want to take the current user, and through a few lookups, find their existing record.  I've run into the limitation on traversing multiple levels of many to one relationships several times in this effort, so I've created some intermediate variables to store values as I go through the lookup process.  I'm able to get to the point where I have the GUID returned and stored in varSurveyInstanceID, however, next I'd like to create a variable containing that record so I can avoid having multiple nested lookups throughout the application.

 

I've tried a few approaches that seemed to work in other areas of the application, but for whatever reason in my OnStart rule I cannot lookup the record by ID:

 

Set(varSurveyInstance,

     Lookup(SurveyInstances, SurveyInstance = varSurveyInstanceID));

 

Gives an error on comparing a record to a GUID

 

Set(varSurveyInstance,

     Lookup(SurveyInstances, SurveyInstance.SurveyInstance = varSurveyInstanceID));

 

Gives an error on invalid use of the '.' operator

 

Set(varSurveyInstance,

     Lookup(SurveyInstances, crad7_surveyinstanceid = varSurveyInstanceID));

 

Gives an error stating it's unable to find the column crad7_surveyinstanceid

 

Having a bit of a struggle believing looking up a record based on it's ID value is so difficult, is there perhaps something I missed in my table setup or in the syntax here?

 

 

 

 

 

 



1 ACCEPTED SOLUTION

Accepted Solutions
v-jefferni
Community Support
Community Support

Hi @tiddlyplatypus ,

 

Since I'm not aware of the structure of that Survey Instance table, I would use Accounts the default table as the example:

in Canvas App:

vjefferni_0-1634543943298.png

 

the Account table in Dataverse and the column:

vjefferni_1-1634543963418.png

 

So, I think the first formula in your post is basically correct, except for varSurvey InstanceID variable may be a record. Therefore, you need to have a check in previous variable creation and make sure it is GUID.

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

1 REPLY 1
v-jefferni
Community Support
Community Support

Hi @tiddlyplatypus ,

 

Since I'm not aware of the structure of that Survey Instance table, I would use Accounts the default table as the example:

in Canvas App:

vjefferni_0-1634543943298.png

 

the Account table in Dataverse and the column:

vjefferni_1-1634543963418.png

 

So, I think the first formula in your post is basically correct, except for varSurvey InstanceID variable may be a record. Therefore, you need to have a check in previous variable creation and make sure it is GUID.

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,291)