Unable to Update Additional Comments field on a form using UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 09:37 PM
I have created a UI action, through that only the "Status" & "Additional comments" field should get updated. if i click the button without entering any "Additional comments" , error message should display. I have written below script in that UI action, its purely server side. Please if u can help me how can i update these two fields only. Rest all fields shouldn’t get updated even i select any value from them.
Script:
if (current.u_additional_comments == '') {
gs.addInfoMessage(current.u_additional_comments);
gs.addErrorMessage("Add Additional comments for Funds Released");
} else {
var comments = current.u_additional_comments;
var irt = new GlideRecord('u_money_request');
irt.addQuery('sys_id', current.sys_id);
irt.query();
while (irt.next()) {
irt.setValue('u_status', 'Money Released');
irt.setValue('u_additional_comments', comments);
irt.update();
gs.addInfoMessage("Status updated for approved Investment to Money Released Successfully");
}
}
action.setRedirectURL(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 10:30 PM
Hi Chandu,
Thanks for reply. Its the correct backend name. I have tried in background script to update the record , its working fine. But not in UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 10:40 PM
Hi Abhilash,
Can you use the below codes for testing and provide your test results
if (current.u_additional_comments == '') {
gs.addInfoMessage(current.u_additional_comments);
gs.addErrorMessage("Add Additional comments for Funds Released");
} else {
var comments = current.u_additional_comments;
var irt = new GlideRecord('u_investment_request');
irt.addQuery('sys_id', current.sys_id);
irt.query();
while (irt.next()) {
irt.setValue('u_additional_comments', comments);
gs.addInfoMessage("Current Comment " + current.u_additional_comments);
irt.update();
gs.addInfoMessage("Status updated for approved Investment to Funds ReleasedSuccessfully");
}
}
action.setRedirectURL(current);
ajd
if (current.u_additional_comments == '') {
gs.addInfoMessage(current.u_additional_comments);
gs.addErrorMessage("Add Additional comments for Funds Released");
} else {
var comments = current.u_additional_comments;
var irt = new GlideRecord('u_investment_request');
irt.addQuery('sys_id', current.sys_id);
irt.query();
while (irt.next()) {
irt.setValue('u_additional_comments', "testing with comments");
gs.addInfoMessage("Current Comment " + current.u_additional_comments);
irt.update();
gs.addInfoMessage("Status updated for approved Investment to Funds ReleasedSuccessfully");
}
}
action.setRedirectURL(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 11:02 PM
Hi Chandu,
tried updating additional comment field by passing string value from UI action script. Not got updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2022 11:19 PM
Hi Abhilash,
looks interesting !!
Can you check with below script
if (current.u_additional_comments == '') {
gs.addInfoMessage(current.u_additional_comments);
gs.addErrorMessage("Add Additional comments for Funds Released");
} else {
var comments = current.u_additional_comments;
var irt = new GlideRecord('u_investment_request');
irt.addQuery('sys_id', current.sys_id);
irt.query();
while (irt.next()) {
irt.setValue('u_additional_comments', "testing with comments");
irt.setWorkflow(false);
gs.addInfoMessage("Current Comment " + current.u_additional_comments);
irt.update();
gs.addInfoMessage("Status updated for approved Investment to Funds ReleasedSuccessfully");
}
}
action.setRedirectURL(current);
can you confirm expect the additional comments another fields are updating via this script in "u_investment_request" table - If No Fields are update Check the BR and Data policy's on u_investment_request" table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2022 09:15 PM
actually we cant use setworkflow(false) method here , as we are triggering a mail after additional comments are getting updated. Still i am not able to find the solution to tackle the issue. As per my knowledge we cant use current object with query, is that right? is this causing this issue?
