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
Super User

@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!

 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (1,851)