- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2024 11:02 AM
I am struggling with how I can set the State to "Review" value(0) in my UI Action.
I have a UI Action to "Return to Review" on the sn_grc_issue table
I have a UIPage with a modal to have the user enter Comments.
This is working - the comments are being added to the record, however, I am not able to set the current state value
If the current state is Closed Complete as an example - when they click the UI Action "Return to Review"
Comments should be added and the state should change to Review
Comments works but I am not able to get the state to change.
Attached are both my UIAction and UIPage XMLS.
Any help would be greatly appreciated!
Thank you.
Tricia
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 08:26 AM
Hi @triciav ,
you can directly set the state value from Ui Action,
Here is a code for that, but please check are you passing the correct value of state (which you are trying to set)
var dialog = new GlideModal("sn_risk_advanced_additional_comments", false, 500);
dialog.setTitle(new GwtMessage().getMessage("Risk Event Comments"));
dialog.setPreference("comments_text", g_form.getValue("comments"));
dialog.setPreference("table_name", g_form.getTableName());
dialog.setPreference("sys_id", g_form.getUniqueValue());
dialog.render();
// Set the state value to "Review"
var gr = new GlideRecord('sn_grc_issue');
if (gr.get(g_form.getUniqueValue())) { // Assuming g_form.getUniqueValue() returns the sys_id of the record
gr.state = '0'; // Assuming '0' represents the state value for "Review"
gr.update();
}
Please hit helpful if it solved your problem and accept this as a solution.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2024 12:11 AM
Hi @triciav,
I have checked your UI Action and UI page you are not updating the state value anywhere in your code so that's why you are not able to update the state value, these are changes that you need to make in your ui page code if you want to update the state to set to review,
function handleSubmit() {
var modal = GlideModal.get();
var actionName = modal.getPreference('methodName');
var commentsElement = gel("comments");
var comments = commentsElement.value.trim();
// Update comments field
g_form.setValue('comments', comments);
// Set the state value to "Review"
var stateValue = '0'; // State value for "Review"
// Set the state value
g_form.setValue('state', stateValue);
GlideModal.get().destroy();
gsftSubmit(null, g_form.getFormElement(), actionName);
}
function handleCancel() {
var modal = GlideModal.get().destroy();
}
Please hit helpful and accept this as a solutin if it solve your problem.
Thanks