MANUALLY Set Person Field in Triggered Actions
Greetings,
I was able to set a Person field using a button & Set Field Value with:
i:0#.f|membership|firstlast@company.com
However, I am not sure how to accomplish the same with Triggered Actions.
I am guessing it similar to how you set an Image Field in Triggered Actions:
'{"type":"thumbnail","fileName":"[[ImageColumn.FileName]]","serverRelativeUrl":"[[ImageColumn.URL]]"}'
I can't find any relevant documentation, so any help would much appreciated!
-
Dear Kilgore ServiceAccount,
single person fields can be set in our background actions (scheduled or triggered -> update item action) using whether the email address only or the user ID if you have it. A person field is technically like a lookup field to a hidden user list.
Kind regards
skybow Support Team
0 -
Greetings,
Outside of Triggered or Scheduled Actions, how can I set a People/User field?! When you using Add a List Item or Update an Item, what is the possible methods for setting a Person field?
I have tried:
[[@User.Email]]
=[[@User.Email]]
[[@User.LoginName]]
=[[@User.LoginName]]
[[@User.Title]]
=[[@User.Title]]
[[@User.Profile.UserName]]
=[[@User.Profile.UserName]]I know that [[User.Id]] was suggested, but that seems to be related to the particular List you are referencing... it is a 2 digit number, and is only useful when Updating an Item in the Current List.
Is there a JavaScript method that can be utilized? Anything? This is a huge pain point.
Any help is much appreciated!
0 -
You can set the value for Person or Group fields by the user's Id.
In case of current user: =[[@User.Id]]
In case of a people picker (single) field: =[[PersonFieldName.ID]]
Sample of a Add list item action on a button in form's command bar (field type in purple):
0 -
Christof, my experience simply seems different.
This is how I have it setup in my Action. [Some fields are text & some are People... this is for debugging.]
This is the result of the Action, in the Target list.
But what is interesting is when I put it into Edit in Grid View... I can interact with and update all fields, until I click inside of one of the 3 People fields... then I have to exit and re-enter grid view to edit anything. They are definitively acting like a lookup, but they aren't populating or acting correctly.
Any thoughts here?
0 -
There was a general issue in evaluating lookup values in expressions - since people picker (person) fields are technically lookup columns, this was most likely the issue you by setting these values.
This was fixed and released yesterday evening by feature update to version 1.3.48
You check by updating your solution to latest version if the persons values can be set now by such expressions: =[[PersonFieldName.ID]]
Please let us know here0 -
Christof,
I just had a chance to try this out and I am having the same experience as before.
Hopefully this is useful...
Thanks,
Taylor
0 -
Hmm, the data from debug output looks correct: number (integer) value of user's id
With this value the Add list item action should set the person field's value correctly.
I will ask my colleagues if there is another issue on that use case0 -
Hi Taylor
We checked this again and for it works as expected in Modern Forms/List actions and in Scheduled/Triggered actions.
Person field can be set by ID.
Probably something is cached in your browser?
If you can't solve the issue please create a support ticket with the following details::- What action is in use and where (Modern Forms, List Actions or Scheduled/Triggered actions)
- Do you use cross site collection Add list item action?
- Do you use singe or muli value selection on person fields
- An export of the action configuration (JSON file) could help us to find the issue
0 -
Christof,
This issue is occurring purely because I was trying to add a List Item from one Site Collection to another Site Collection...which why I noted that the Id only being 1-2 digits didn't make sense to me.
Even when using pure SharePoint REST you cannot use '_api/web/GetByTitle/items' to create List Items with People fields...
You have to create the Item with GetByTitle and then utilize '_api/web/lists/GetByTitle('Title')/items(ID)/validateUpdateListItem' to add People fields to the List, in another Site Collection.
I solved this with Power Automate as such:
0 -
When adding/updating items cross site collection you can't use the user's ID from current site because these are different from site to site.
In this example of adding a new item cross site with current user in a people picker field by client-side List Action, I used the ensureUser function in context of target site to get its ID from target site:
return new Promise((resolve, reject) => {
[[@Variables.SitzungAppSiteServerRelUrl]] is set as server relative url of target site
var userLogin = [[@User.LoginName]];
var context = new SP.ClientContext([[@Variables.SitzungAppSiteServerRelUrl]]);
var web = context.get_web();
var user = web.ensureUser(userLogin);
context.load(user);
context.executeQueryAsync(function(){
var val = new SP.FieldUserValue();
val.set_lookupId(user.get_id());
resolve(val);
}, function(sender, args){
reject("User not found in target site. " + args.get_message());
});
});0 -
Christof,
The above sample has been serving me well, thank you!
I am attempting to use the above, within a SelectedItems loop, and I running into an issue where basically the
var userLogin = [[@User.LoginName]]
is for a user who has been offboarded from O365.
If I have 5 items selected, and the first 3 are good... the first 3 will function correctly, and the entire loop will terminate on the 4th, skipping the 5th.
My 3 thoughts on how to maybe approach:
Should I add an IF statement in the Javascript to tell it to ignore providing the People Picker field a value?
Can the new Scope action be utilized here?
Or should I evaluate the Javascript in a Condition, and then either update the PeoplePicker if successful or set a Status field if rejected?
Would appreciate your thoughts on what would work best!
Thanks,
Taylor
0 -
Hi Taylor
hmm, strange, since the ensureUser(...) function should add user if it not exists to target site...
Yes, use the Scope action here to prevent from stopping the action flow when this error occurs - this way you will have no skipped items anymore.
With the scope you can do this in one step. Place your actions inside the scope and place a Update item action which set Status fields in Has failed block.0 -
Christof,
I noticed the same in my own code, so I decided to paste your original (from above), and this is what I am seeing for web variable... (I am not sure what this telling me)
I am seeing this in the console log:
6.resource-codeeditor_73152c2fdea7a8924b12.js:2 Uncaught ReferenceError: Cannot access 't' before initialization
at 6.resource-codeeditor_73152c2fdea7a8924b12.js:2:915195
at 6.resource-codeeditor_73152c2fdea7a8924b12.js:2:915268
at Array.map (<anonymous>)
at new a (6.resource-codeeditor_73152c2fdea7a8924b12.js:2:915092)
at get brackets (6.resource-codeeditor_73152c2fdea7a8924b12.js:2:1682591)
at Object.getBracketsSupport (6.resource-codeeditor_73152c2fdea7a8924b12.js:2:1691862)
at Oe._matchBracket (6.resource-codeeditor_73152c2fdea7a8924b12.js:2:3091337)
at Oe.matchBracket (6.resource-codeeditor_73152c2fdea7a8924b12.js:2:3090595)
at _._recomputeBrackets (6.resource-codeeditor_73152c2fdea7a8924b12.js:2:1654296)
at _._updateBrackets (6.resource-codeeditor_73152c2fdea7a8924b12.js:2:1653420)0 -
You have most likely no variable named SitzungAppSiteServerRelUrl in your action builder defined. Replace it with placeholder of your variable containing the server relative url of target site.
You see the red underlined "@"? All errors below are subsequent marked errors.0
Please sign in to leave a comment.
Comments
14 comments