cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dallenap
Advocate I
Advocate I

Missing Lookup Values After Patch

Hi,

 

I am running into a problem where after a patch I'm loosing related lookup values on my entity.

 

Upon starting the app, the user enters an application number and clicks a button setting a global variable to hold the application entity data and a global variable to hold the application id.  The OnSelect of the button is:

 

Set(varApplicationId, Value(InputApplicationId.Text));
Set(
varApplication,
LookUp(
'Applications',
'Application Id' = varApplicationId
));

 

 

The application entity has a relationship with Account.  At this point, I can access the account's name by varApplication.Account.Name

 

Later the user updates a value of the application and the updated value is patched back to the CDS.  Here is the code for that:

 

Set(varApplication, Patch(
    'Applications',
    LookUp(
        'Applications',
        'Application Id' = varApplicationId
    ),
    {'Modifier': Value(InputModifier.Text)}
));

 

 

After this patch, I can no longer access the Account Name.  The related Account lookup field is not populated.

 

I've tried the following and it also fails.  The patch works but the related Account information is empty.

 

 Patch(
    'Applications',
    LookUp(
        'Applications',
        'Application Id' = varApplicationId
    ),
    {'Modifier': Value(InputModifier.Text)};
Set(varApplication,
   LookUp(
   'Applications',
   'Application Id' = varApplicationId));

 

 

How can I ensure that the related lookup values remain populated after a patch?

 

Thanks for any help.

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @dallenap ,

 

Please try with this,

Set(varApplication,
   LookUp(
   AddColumns('Applications',"Test",Account.Name),
   'Application Id' = varApplicationId));

Then the varApplication.Account.Name or varApplication.Test can work well.

Sik

View solution in original post

1 REPLY 1
v-siky-msft
Community Support
Community Support

Hi @dallenap ,

 

Please try with this,

Set(varApplication,
   LookUp(
   AddColumns('Applications',"Test",Account.Name),
   'Application Id' = varApplicationId));

Then the varApplication.Account.Name or varApplication.Test can work well.

Sik

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (74,635)