Modern audience in document library - updating audience in document library item from SPfX

%3CLINGO-SUB%20id%3D%22lingo-sub-2410334%22%20slang%3D%22en-US%22%3EModern%20audience%20in%20document%20library%20-%20updating%20audience%20in%20document%20library%20item%20from%20SPfX%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2410334%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EWe're%20building%20an%20SPX%20App%20to%20update%20audiences%20for%20documents%20stored%20in%20a%20library.%20We%20use%20modern%20audience.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EWe%20have%20succeeded%20with%20the%20following%20PowerShell%20approach%20(but%20we%20need%20the%20SPFx%20option%20for%20the%20app)%3A%26nbsp%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3ESet-PnPListItem%20-List%20%24listName%20-Identity%205%20-Values%20%40%7B%22_ModernAudienceTargetUserField%22%20%3D%20%2218%22%7D%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3EBoth%20Audiences%20(%20_ModernAudienceTargetUserField)%20and%20IdAudiences%20(_ModernAudienceAadObjectIds)%20is%20updated%20with%20valid%20data.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EHowever%2C%20we%20were%20unsuccessful%20when%20trying%20to%20update%20data%20in%20_ModernAudienceTargetUserField%20or%20OData__ModernAudienceTargetUserField.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EIs%20this%20type%20of%20approach%20even%20expected%20to%20be%20supported%3F%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EWhat%20is%20the%20expected%20structure%20of%20the%20obect%20for%20Audience%20column%3F%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2410334%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAudience%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDocument%20Library%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Regular Visitor

We're building an SPX App to update audiences for documents stored in a library. We use modern audience.

 

We have succeeded with the following PowerShell approach (but we need the SPFx option for the app): 
Set-PnPListItem -List $listName -Identity 5 -Values @{"_ModernAudienceTargetUserField" = "18"}
Both Audiences ( _ModernAudienceTargetUserField) and IdAudiences (_ModernAudienceAadObjectIds) is updated with valid data.

 

However, we were unsuccessful when trying to update data in _ModernAudienceTargetUserField or OData__ModernAudienceTargetUserField from SPfx code. 

Is this type of approach even expected to be supported? 

What is the expected structure of the obect for Audience column? 

0 Replies