cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nparent
Regular Visitor

Unable to attach a note to a lead just created with a pach

I have an application who create a lead and attache a note with an image take on camera.      It seem to correctly create the lead, but when it's time to create the note, this message apear :   unable to find the Lead with ID :  xxxxxxxxx

 

So I see it's really creating the lead... the Guid returned is the good one...   maybe synchronisation issue ?    

 

You have to note that it's working in an other instance (using english name instead of french), but not on the french one....   

 

ClearCollect(
leadCollection;
Defaults(Leads);
Patch(
Leads;
{Topic: topic.Text}
)
);;
Patch(
Notes;
Defaults(Notes);
{
subject: topic.Text;
notetext: topic.Text;
_objectid_value: Last(leadCollection).leadid;
_objectid_type: "leads";
filename: "lead.png";
documentbody: If(
StartsWith(
First(Image).fileBody;
"data:image/png;base64,"
);
Replace(
First(Image).fileBody;
1;
22;
""
);
First(Image).fileBody
)
}
);;
Notify("Enregistrement Complété ! N'oublie pas d'aller mettre à jour dans Dynamics")

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @nparent ,

Based on the error message that you mentioned, It seems to tell that there is something wrong with the value you provided for the _objectid_value property in your Patch function.

I agree with @RandyHayes 's thought almost. Based on the formula that you provided, I think there is something wrong with it. Please modify your formula as below:

ClearCollect(
       leadCollection;
       Patch(              /* <-- Modify your formula here */
             Leads;
             Defaults(Leads);   /*<-- Type Defaults() function here */
             {Topic: topic.Text}
       )
);;
Refresh('Leads'); /* <-- Add this formula */
Patch(
Notes;
Defaults(Notes);
{
subject: topic.Text;
notetext: topic.Text;
_objectid_value: Last(leadCollection).leadid;
_objectid_type: "leads";
filename: "lead.png";
...
...
);;
Notify("Enregistrement Complété ! N'oublie pas d'aller mettre à jour dans Dynamics")

If the issue still exists, please consider take a try to re-create a new connection to your Entities within your app, then try above solution again, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
RandyHayes
Super User III
Super User III

@nparentat a glance - it doesn't look like you are actually creating the Leads record.  Your first statement will create a collection called leadCollection, that will have the first record as the default values and nothing for the second (as I believe your Patch statement would fail).

Perhaps what you are looking for is something like this:

   ClearCollect(leadCollections; Patch(Leads; Defaults(Leads); {Topic: topic.Text}));;

 

Hopefuly that will help some

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
v-xida-msft
Community Support
Community Support

Hi @nparent ,

Based on the error message that you mentioned, It seems to tell that there is something wrong with the value you provided for the _objectid_value property in your Patch function.

I agree with @RandyHayes 's thought almost. Based on the formula that you provided, I think there is something wrong with it. Please modify your formula as below:

ClearCollect(
       leadCollection;
       Patch(              /* <-- Modify your formula here */
             Leads;
             Defaults(Leads);   /*<-- Type Defaults() function here */
             {Topic: topic.Text}
       )
);;
Refresh('Leads'); /* <-- Add this formula */
Patch(
Notes;
Defaults(Notes);
{
subject: topic.Text;
notetext: topic.Text;
_objectid_value: Last(leadCollection).leadid;
_objectid_type: "leads";
filename: "lead.png";
...
...
);;
Notify("Enregistrement Complété ! N'oublie pas d'aller mettre à jour dans Dynamics")

If the issue still exists, please consider take a try to re-create a new connection to your Entities within your app, then try above solution again, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (21,470)