- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 09:49 AM
Hey there Community,
I am finishing up my NextGen cohort with a project where we are building an application. It may not be the most or right way to do it, but instead of using a typical form, I am trying to use a button to update a record with the current user's information. I have a table that has a field to assign a user. I currently have the button updating a client state with the record's Sys ID and also executing the data resource update record. In the picture, you'll see my table, the client state parameter and the field value, which I have set to the field I want to 'User Assigned is (dynamic) Me.' I have played around with the record field using different input methods and searched lots of forums for utilization of the update record, but I can't seem to figure it out. Any help would be awesome.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 01:48 PM
Update record doesn't seem to work well with dymanic values.
When you switch over to script more you'll see something like this:
The data broker doesn't know how to process assigned_toDYNAMIC...
Instead I think you need a script like this one:
/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({api, event}) {
return {
table: "incident",
recordId: api.state.currentRecord,
templateFields: "assigned_to=" + api.context.session.user.sys_id,
useSetDisplayValue: null
};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 01:00 PM
Not sure how to edit my post, so I'll post a reply.
It took me a minute, but I figured out that 'is (dynamic)' is not suitable for the Update Record data resource. I was able to determine that I needed to use is '@context.session.user.sys_id'. However, the same trick doesn't work with the list format. I'd like users to add themselves to a user list by clicking a different button and using the Update Record resource, but none of the field values I'm trying are working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 01:48 PM
Update record doesn't seem to work well with dymanic values.
When you switch over to script more you'll see something like this:
The data broker doesn't know how to process assigned_toDYNAMIC...
Instead I think you need a script like this one:
/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({api, event}) {
return {
table: "incident",
recordId: api.state.currentRecord,
templateFields: "assigned_to=" + api.context.session.user.sys_id,
useSetDisplayValue: null
};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 03:13 PM
I didn't use script, but I did add in the context piece and it worked! However, now when I try to apply the same logic to add the user's name to a list field, it won't work. I tried using the script you posted, but it didn't work. Any more suggestions? If not, I'll have to go with something completely different.