Share via

Patch with Empty Managed Metadata type

Anonymous
2024-11-27T22:37:54+00:00

I have a patch function that creates new records in a Sharepoint list. It works well. However, it does not work when I do not populate the "Trade" Managed Metadata field. The "Trade" field is a dropdown that uses a Term Store selection. When this is left blank, I get the below error when trying to patch. *Note "Trade" is not a required field in the Sharepoint list. Any ideas why this is happening? Patch('List-Evidence_Tracker',Defaults('List-Evidence_Tracker'),{CriteriaID: LookUp('List-Criteria',Criteria = DataCardValueEvCriteria.Selected.Value,ID),EvidenceTypeID: LookUp('List-EvidenceType',Title = DataCardValueEvType.Selected.Value,ID),'Evidence-Title': DataCardValueEvTitle.Text,'Link to Evidence': DataCardValueEvLink.Text,ResponsibleID: LookUp('List-Responsible',Title = DataCardValueEvResponsible.Selected.Value,ID),Trade: {'@odata.type': "Microsoft.Azure.Connectors.SharePoint.SPListExpandedTaxonomy",TermGuid: DataCardValueEvTrade.Selected.TermGuid,WssId: DataCardValueEvTrade.Selected.WssId,Label: DataCardValueEvTrade.Selected.Label,Path: DataCardValueEvTrade.Selected.Path,Value: DataCardValueEvTrade.Selected.Value},Subcontractor: DataCardValueEvSubcon.Text,'Planned Collection Date': DataCardValueEvPlannedDate.SelectedDate,'Actual Collection Date': DataCardValueEvActualDate.SelectedDate,'Submitted to ESDC?': DataCardValueEvSubmitESDC.Value,'Collection Status Comments': DataCardValueEvComments.Text});If(// check if there were any errors when the item was submitted!IsEmpty(Errors('List-Evidence_Tracker')),// if true, show any error messageNotify("Criteria submission failed",NotificationType.Error),// else, go to success screenResetForm(frmAddEvidence);Navigate(scrnMainScreen););

Microsoft 365 and Office | SharePoint | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-11-28T00:54:05+00:00

    Hi Maria,

    As per the shared information, it looks like you're encountering an issue with the "Trade" Managed Metadata field when it is left blank. In this situation, as community moderators here mainly focus on out-of-box features in SharePoint Online, to make sure you can get the professional and appropriate support to help modify the patch function, please post in Microsoft Q&A Community, which is the specific channel to handle such developed customization. You may use SharePoint or SharePoint Development tag when" Ask a question".

    Image

    Meanwhile, I will keep your thread open here and welcome other community members or MVPs may share their suggestions and experience for you. And from my online search, some users addressed the issue to add a condition to check if the "Trade" field is empty and it will be set to Blank() instead of trying to patch an empty Managed Metadata object.

    Please correct me if I made any misunderstanding or if there have anything else I can do for you.

    Your patience is highly appreciated. Hope you a nice day and stay safe!

    Best Regards,

    Mia

    Patch( 'List-Evidence_Tracker', Defaults('List-Evidence_Tracker'), { CriteriaID: LookUp('List-Criteria', Criteria = DataCardValueEvCriteria.Selected.Value, ID), EvidenceTypeID: LookUp('List-EvidenceType', Title = DataCardValueEvType.Selected.Value, ID), 'Evidence-Title': DataCardValueEvTitle.Text, 'Link to Evidence': DataCardValueEvLink.Text, ResponsibleID: LookUp('List-Responsible', Title = DataCardValueEvResponsible.Selected.Value, ID), Trade: If( IsBlank(DataCardValueEvTrade.Selected.TermGuid), Blank(), { '@odata.type': "Microsoft.Azure.Connectors.SharePoint.SPListExpandedTaxonomy", TermGuid: DataCardValueEvTrade.Selected.TermGuid, WssId: DataCardValueEvTrade.Selected.WssId, Label: DataCardValueEvTrade.Selected.Label, Path: DataCardValueEvTrade.Selected.Path, Value: DataCardValueEvTrade.Selected.Value } ), Subcontractor: DataCardValueEvSubcon.Text, 'Planned Collection Date': DataCardValueEvPlannedDate.SelectedDate, 'Actual Collection Date': DataCardValueEvActualDate.SelectedDate, 'Submitted to ESDC?': DataCardValueEvSubmitESDC.Value, 'Collection Status Comments': DataCardValueEvComments.Text } );

    Was this answer helpful?

    0 comments No comments