- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a Catalog Item with a Requested for variable. I am mapping it to the RITM Requested for field using a Workflow Run Script:
current.requested_for = current.variables.requested_for;
In the RITM List View, it shows the selected Requested for user correctly. But when I open the RITM in Form View, it shows the logged-in user instead.
I also removed the default value from the Requested for field, but the issue still exists.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
This is almost always the dictionary default on requested_for firing on form load, not the workflow script failing.
List view reads the stored value. Form view re-applies javascript:gs.getUserID() (or a display BR / onLoad client script), so you see the logged-in user.
1. Open the dictionary for sc_req_item.requested_for AND sc_request.requested_for and clear the Default value. OOTB it is often javascript:gs.getUserID().
2. Confirm which field the form is actually showing. If it is request.requested_for (dotted), your workflow run script on the RITM never updates what the form displays. Set the parent Request too.
3. Move the mapping out of the workflow run script and into a before insert Business Rule on sc_req_item:
(function executeRule(current, previous) {
var reqFor = current.variables.requested_for;
if (reqFor) {
current.requested_for = reqFor;
var req = current.request.getRefRecord();
if (req.isValidRecord()) {
req.requested_for = reqFor;
req.update();
}
}
})(current, previous);
4. Check for a client script or UI policy on sc_req_item that sets requested_for to g_user.userID onLoad.
Then open the RITM from the list again (do not use browser back). The form should match the list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
The default value removal was a good idea just to make sure - though that shouldn't override when there already is a value. Two things come to mind 1) On the sc_req_item table, do you have any display Business Rules, Client Scripts, or scripted UI Policies that could be affecting this field? If you open an RITM related to any other Catalog Item where the Requested for field has a value other than the logged in user, does it also update to the logged in user? To that point, even opening this same test case RITM where the value shows logged in user if you change it to yet a different user then save the form (not submit, so that it stays on the screen), does it change again as the form is re-loaded? This would help prove that it's not the requested for variable or the script setting the value that is the issue. if those two are 'no' then 2) maybe the value isn't getting set to a valid user, even though it appears as such in the list view, though this would likely result in a blank value when viewing the record, not an updated once since the default is removed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
This is almost always the dictionary default on requested_for firing on form load, not the workflow script failing.
List view reads the stored value. Form view re-applies javascript:gs.getUserID() (or a display BR / onLoad client script), so you see the logged-in user.
1. Open the dictionary for sc_req_item.requested_for AND sc_request.requested_for and clear the Default value. OOTB it is often javascript:gs.getUserID().
2. Confirm which field the form is actually showing. If it is request.requested_for (dotted), your workflow run script on the RITM never updates what the form displays. Set the parent Request too.
3. Move the mapping out of the workflow run script and into a before insert Business Rule on sc_req_item:
(function executeRule(current, previous) {
var reqFor = current.variables.requested_for;
if (reqFor) {
current.requested_for = reqFor;
var req = current.request.getRefRecord();
if (req.isValidRecord()) {
req.requested_for = reqFor;
req.update();
}
}
})(current, previous);
4. Check for a client script or UI policy on sc_req_item that sets requested_for to g_user.userID onLoad.
Then open the RITM from the list again (do not use browser back). The form should match the list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @mohithreddy ,
Thank you so much
var req = current.request.getRefRecord();
req.requested_for = current.variables.requested_for;
req.update();
current.requested_for=current.variables.requested_for;
