cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KimberlyM
Helper IV
Helper IV

Create new item and patch ID number of new item to two lists - ID number not patching

I am trying to get my new form to make an entry into my Lead_History in the background. My "Note" data and "HistoryDate" are patching into my list but my "LeadID" number is not patching. Suggestions on how I can make this work?

FYI: I have 2 SharePoint lists: one for my main data called Lead_Data and one for my tracking of my notes called Lead_History. NewForm submits to Lead_Data.

My forms OnSuccess:

//ADD NEW LEAD CREATED ENTRY INTO LEAD_HISTORY SHAREPOINT LIST UPON CREATION OF NEW LEAD
Patch(Lead_History, Defaults(Lead_History), {Title: "", Note: "New Lead Created", HistoryDate: Text( Now(), "[$-en-US]mm/dd/yyyy hh:mm:ss"), LeadID: NewForm.LastSubmit.ID});


My submit button OnSelect:

//SEND MAIL START

ClearCollect(ccEmails,{Mail: LookUp(Agents, FullName = ndd_LeadMember1.Selected.FullName, EmailAddressCC)}); 
Collect(ccEmails,{Mail: LookUp(Agents, FullName = ndd_LeadMember2.Selected.FullName, EmailAddressCC)});
Collect(ccEmails,{Mail: LookUp(Agents, FullName = ndd_LeadMember3.Selected.FullName, EmailAddressCC)});
Collect(ccEmails,{Mail: LookUp(Agents, FullName = ndd_LeadMember4.Selected.FullName, EmailAddressCC)});

Office365.SendEmailV2(LookUp(Agents, FullName = ndd_AssignedTo.Selected.FullName, EmailAddressT), 
//Subject Line 
ndd_AssignedTo.SelectedText.Value & ", you have a new lead!", 
//Message Line 
"<strong>Name: </strong>" & ntxt_FirstName & " " & ntxt_LastName
& "<br><strong>Email: </strong>" & ntxt_Email
& "<br><strong>Phone: </strong>" & ntxt_Phone 
& "<br><strong>Address: </strong>" & ntxt_Unit & ", " & ntxt_Street & ", " & ntxt_City & ", " & ntxt_Province 
& "<br><strong>Listing Information: </strong>" & ndd_ListingType.Selected.Value & ", " & ndd_PropertyType.Selected.Value & ", " & ndd_Location.Selected.Value
& "<br><strong>Source: </strong>" & ndd_Source.Selected.Value

& "<br><br><i>Other Lead Members CC'ed: " & ndd_LeadMember1.Selected.FullName & ", " & ndd_LeadMember2.Selected.FullName & ", " & ndd_LeadMember3.Selected.FullName & ", " & ndd_LeadMember4.Selected.FullName & "</i>", 
{Cc: Concat(ccEmails,Mail,";")}
);

//SUBMIT FORM AFTER THE OTHER PROCESSES SO THAT THE FORM DATA DOES NOT BECOME INVALID
SubmitForm(NewForm);

//NAVIGATE AND RESET THE NEW FORM
Navigate( Dashboard, ScreenTransition.Fade ); ResetForm(NewForm);
1 ACCEPTED SOLUTION

Accepted Solutions

 

//ADD NEW LEAD CREATED ENTRY INTO LEAD_HISTORY SHAREPOINT LIST UPON CREATION OF NEW LEAD
Set(varNewLeadID, NewForm.LastSubmit.ID);
Patch(Lead_History, Defaults(Lead_History), {Title: "", Note: "New Lead Created", HistoryDate: Text( Now(), "[$-en-US]mm/dd/yyyy hh:mm:ss"), LeadID: varNewLeadID});

//NAVIGATE AND RESET THE NEW FORM
Navigate( Dashboard, ScreenTransition.Fade ); ResetForm(NewForm);

I was able to work it out! Must have been early morning, after Canadian Thanksgiving brain blunders, as I have no idea why I couldn't put this together this morning!

 

View solution in original post

5 REPLIES 5
cds
Impactful Individual
Impactful Individual

hey Kimberly lol 

 

try setting var = Lastsubmit.ID before patch function and use {LeadID: var}

mdevaney
Super User III
Super User III

@KimberlyM
What column type is LeadID in SharePoint? Can you please check to See if LeadID is a number type column? Sometimes data does not save for me because the data going in does not match the column.
v-xida-msft
Community Support
Community Support

Hi @KimberlyM ,

Could you please share a bit more about the LeadID column in your Lead_History SP List? Is it a Number type column or Single text type column?

 

Based on the Patch function that you mentioned, I could not find any syntax error with it. According to the OnSelect formula of Submit button, I think this issue may be related to the ResetForm(NewForm) formula.

 

Please consider modify the OnSelect property of the "Submit" button to following:

//SEND MAIL START
ClearCollect(ccEmails,{Mail: LookUp(Agents, FullName = ndd_LeadMember1.Selected.FullName, EmailAddressCC)}); 
Collect(ccEmails,{Mail: LookUp(Agents, FullName = ndd_LeadMember2.Selected.FullName, EmailAddressCC)});
Collect(ccEmails,{Mail: LookUp(Agents, FullName = ndd_LeadMember3.Selected.FullName, EmailAddressCC)});
Collect(ccEmails,{Mail: LookUp(Agents, FullName = ndd_LeadMember4.Selected.FullName, EmailAddressCC)});
Office365.SendEmailV2(LookUp(Agents, FullName = ndd_AssignedTo.Selected.FullName, EmailAddressT), 
//Subject Line 
ndd_AssignedTo.SelectedText.Value & ", you have a new lead!", 
//Message Line 
"<strong>Name: </strong>" & ntxt_FirstName & " " & ntxt_LastName
& "<br><strong>Email: </strong>" & ntxt_Email
& "<br><strong>Phone: </strong>" & ntxt_Phone 
& "<br><strong>Address: </strong>" & ntxt_Unit & ", " & ntxt_Street & ", " & ntxt_City & ", " & ntxt_Province 
& "<br><strong>Listing Information: </strong>" & ndd_ListingType.Selected.Value & ", " & ndd_PropertyType.Selected.Value & ", " & ndd_Location.Selected.Value
& "<br><strong>Source: </strong>" & ndd_Source.Selected.Value
& "<br><br><i>Other Lead Members CC'ed: " & ndd_LeadMember1.Selected.FullName & ", " & ndd_LeadMember2.Selected.FullName & ", " & ndd_LeadMember3.Selected.FullName & ", " & ndd_LeadMember4.Selected.FullName & "</i>", 
{Cc: Concat(ccEmails,Mail,";")}
);
//SUBMIT FORM AFTER THE OTHER PROCESSES SO THAT THE FORM DATA DOES NOT BECOME INVALID
SubmitForm(NewForm)

Set the OnSuccess property of the Edit form (NewForm) to following:

//ADD NEW LEAD CREATED ENTRY INTO LEAD_HISTORY SHAREPOINT LIST UPON CREATION OF NEW LEAD
Patch(
Lead_History,
Defaults(Lead_History),
{
Title: "",
Note: "New Lead Created",
HistoryDate: Text( Now(), "[$-en-US]mm/dd/yyyy hh:mm:ss"),
LeadID: NewForm.LastSubmit.ID
}
); //NAVIGATE AND RESET THE NEW FORM Navigate(Dashboard, ScreenTransition.Fade); /* <-- Put your Navigate formula and ResetForm formula here */
ResetForm(NewForm);

Please consider take a try with above solution, then 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.

@cds@mdevaney  I have tried setting the variable but I don't know how to set a variable to the lastsubmit. It doesn't give me this option. 
In my main SPList: Lead_Data ID column I have no idea what it is as it is the ID column that "comes with" the list. 
In my second SPList: Lead_History my ID column is set as a number as I assume that is what the ID column is set to. 

So now on my OnSuccess of my form I have

Set(varMakeID, Lead_Data.ID)
Patch(Lead_History, Defaults(Lead_History), {Title: "", Note: "New Lead Created", HistoryDate: Text( Now(), "[$-en-US]mm/dd/yyyy hh:mm:ss"), LeadID: varMakeID});

As I said above I know my Set won't work as I am not stating what ID number to pull from Lead_Data. 
I did test to make sure that a miracle didn't happen. FYI, it didn't. 

Any ideas?

 

//ADD NEW LEAD CREATED ENTRY INTO LEAD_HISTORY SHAREPOINT LIST UPON CREATION OF NEW LEAD
Set(varNewLeadID, NewForm.LastSubmit.ID);
Patch(Lead_History, Defaults(Lead_History), {Title: "", Note: "New Lead Created", HistoryDate: Text( Now(), "[$-en-US]mm/dd/yyyy hh:mm:ss"), LeadID: varNewLeadID});

//NAVIGATE AND RESET THE NEW FORM
Navigate( Dashboard, ScreenTransition.Fade ); ResetForm(NewForm);

I was able to work it out! Must have been early morning, after Canadian Thanksgiving brain blunders, as I have no idea why I couldn't put this together this morning!

 

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

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 (93,045)