web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create new item and pa...
Power Apps
Answered

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

(0) ShareShare
ReportReport
Posted on by 193

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);
Categories:
  • cds Profile Picture
    1,001 on at

    hey Kimberly lol 

     

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

  • mdevaney Profile Picture
    29,993 Moderator on at
    @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 Profile Picture
    Microsoft Employee on at

    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,

  • KimberlyM Profile Picture
    193 on at

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

  • Verified answer
    KimberlyM Profile Picture
    193 on at

     

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

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard