PowerApps Patch new SharePoint list item with conditional / dynamically adding fields

Important 

if you get an error that says:

powerapps patch sharepoint list error the specified column "" does not exist the column with the most similar name is ""

that would be because you use the column DisplayName instead of the InternalName


Solution:


 Set(oItem, {

    Title:me.displayName,

    EmpITref:{Id:meSP.ID, Value:meSP.Title},

    EducationLevel:EducationLevel.SelectedText.Value,

    CertCount:vis,

    WorkYearsExp:WorkYearsExp.SelectedText.Value,

    anythingElse:anythingElse.Text,

    DigitalSignature:DigSign.Text

});


If(vis<>0, Set( oItem, Patch (oItem, {

    Cert1_x002d_OrgAd:cert1_orgAd.Text, 

    Cert1_x002d_Title: cert1_title.Text,

    Cert1_x002d__x0023_:cert1_No.Text, 

    Cert1_x002d_GrantDate:cert1_grant.SelectedDate,

    Cert1_x002d_exp_x002e_Date:cert1_exp.SelectedDate

})));



If(vis=2, Set( oItem, Patch (oItem, {

    Cert2_x002d_OrgAd:cert2_orgAd.Text, 

    Cert2_x002d_Title: cert2_title.Text,

    Cert2_x002d__x0023_:cert2_No.Text, 

    Cert2_x002d_GrantDate:cert2_grant.SelectedDate,

    Cert2_x002d_exp_x002e_Date:cert2_exp.SelectedDate

})));



Patch('Some List', Defaults('Some List'), oItem)




Comments

Popular posts from this blog

CPanel - WHM - change sending email via server to email Relay (email supplier SMTP) (mailgun)

OverTheWire[.com] Bandit Walkthrough - JUST HINT, NO SPOILERS

JS Link Tutorial, Sharepoint 2013