cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bgarcial
Level: Power Up

Powerapps: problem specifying DataCard record Id for Patch function

I have a PowerApps CanvasApp, inside a CRM environment. It consists of a survey form of this way:

  • From a  DataCard I am getting the Account record, keeping in mind that here there is an interaction with Account source entity.

 

 

 

 

 

DataSourceInfo([@Accounts], DataSourceInfo.MaxLength, "name")

 

 

 

 

 

 

 This process is working because I can see the Account selected to include this application inside the CRM Account form. I mean the name Bernardo Garcia

 

vVlfX

 

I want to set the Submit action in its Button, in order to pass the accountid in the formula. I want here use the accountid of the context Account which is active and using CRM.

In the new_account key here, I don't know how to pass the accountid, so I have the following as a test:

 

 

 

 

 

Patch(
    Surveys,Defaults(Surveys),                  
    {
        new_city:DataCardCityValue,

        # IS HERE WHERE I WANT TO PASS THE accountid. It is a test  
        new_account:First(Filter(Accounts,'Address 1: Primary Contact Name')),
        
        new_phone:DataCardPhoneValue,
        new_name:TextInputName.Text,   
        new_issurveydone:ToggleSurveyDone.Value,
        new_noofemployee:Value(NoEmployeeSlider.Value),
        new_email:TextInputEmail.Text,
        new_surveydate:SurveyDatePicker.SelectedDate,
        new_signature:SignaturePenInput.Image
    });

 

 

 

 

 

With this formula in the Submit button I manage to store in my Survey entity in CRM the survey data, but I am not getting the value regarding to Account

I am trying to get the accountid using the Value function, but of course I am asking for the Text value here

 

j62OI

 

I have been trying according to this explanation, and this another article , but is not clear for me how should I set the parameter inside the `Patch` function.

If someone can point me in the right direction, I will appreciate it.

2 REPLIES 2
Community Support Team
Community Support Team

Re: Powerapps: problem specifying DataCard record Id for Patch function

Hi @bgarcial ,

Could you tell me

1)the relationship between Surveys entity and Accounts entity?

2) is new_account a lookup field?
3)describe more clearly the meaning of this formula?

Filter(Accounts,'Address 1: Primary Contact Name')

 Usually, we use this kind of formula to update lookup field:

Patch(entity,Defaults(entity),{lookupfieldname:DataCardValue.Selected,....})

set the lookup field's drop down's Items: 

Choices([@YourEntity].lookupColumn)    

 Or like this:

Patch(
    Surveys,Defaults(Surveys),                  
    {
        new_city:DataCardCityValue,
        new_account:LookUp(Accounts,condition)),
        
        ....
    });

The lookup formulas should be like:

LookUp(Accounts,'Address 1: Primary Contact Name'=....)  //if 'Address 1: Primary Contact Name' is a field name.

 

 

 

Please refer these two docs about updating lookup field:

https://powerusers.microsoft.com/t5/Common-Data-Service-for-Apps/Problem-with-lookup-fields/m-p/3601...

https://powerusers.microsoft.com/t5/Common-Data-Service-for-Apps/Patching-User-Lookup-on-CDM/m-p/366...

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
bgarcial
Level: Power Up

Re: Powerapps: problem specifying DataCard record Id for Patch function

Hi, @v-yutliu-msft Thanks for reaching out.

 

I want to answer your questions.

 

2) is new_account a lookup field?

Yes new_account is a Lookup field. You can see it here.

wcAO2fyGvm

 

1. the relationship between Surveys entity and Accounts entity?

 

Yes, it was a small and important detail which I forgot. My apologies.

I am trying to set up the relationship between Account and Surveys,  1 : N

But I have some doubts here:

At the Lookup Field section, do I need to reference the new_account field?

 

wI72QCjdrH

 

3)describe more clearly the meaning of this formula?

 

 

Filter(Accounts,'Address 1: Primary Contact Name') 

 

 

Really It was only a test to verify despite I wasn't getting the accountid (because of the relationship between Surveys and Account ... I guess) I can store data in my Surveys Entity, so, really this value I don't want to reference it in any specific place.

It was just to fill something in the new_account key.

 

The Address 1: Primary Contact Name'  yes, it is a Field, in the Accounts form, and obviously in the Account Entity

 

61xh0mQsNT

 

But I don't need it in my Formula process.

 

The other recommendations about reference the lookup field inside Patch Formula look nice, but I suppose that I need to set up the relationship first in order to continue right?

 

 

 

 

 

 

Helpful resources

Announcements
thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (5,456)