Action not authorized info message is displayed if i change the state on click of UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 05:31 AM
Hi,
I have a requirement where on click of UI Action the risk assessment form moves from "ready to assess" state to "monitor" state and setting in between states complete. But, when i click the button the form moves to monitor but there is one info message coming up "Action Not Authorized". What could be the issue here?
Below is the code i have written:
Script Include 1(client callable )
var RiskAssessmentAJAX1 = Class.create();
RiskAssessmentAJAX1.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
generateResponses: function() {
var currAsmtId = this.getParameter('sysparm_currAsmtId');
return new aRiskAssessments().generateResponsesFor(currAsmtId);
},
Script Include 2 (server side)
var aRiskAssessments = Class.create();
aRiskAssessments.prototype = {
initialize: function() {},
_generateResponsesFor: function(currentAsmt) {
var isRiskApplicable;
var currentAsmnt = new GlideRecord('sn_risk_advanced_risk_assessment_instance');
currentAsmnt.addEncodedQuery('sys_id=' + currentAsmt);
currentAsmnt.query();
if (currentAsmnt.next()) {
isRiskApplicable = currentAsmnt.getValue('u_is_risk_applicable');
gs.info('value is ' + isRiskApplicable);
if (isRiskApplicable == 'yes') {
currentAsmnt.setValue('state', 1);
currentAsmnt.update();
currentAsmnt.setValue('state', 2);
currentAsmnt.update();
currentAsmnt.setValue('state', 4);
currentAsmnt.update();
currentAsmnt.setValue('state', 5);
currentAsmnt.update();
currentAsmnt.setValue('state', 7);
currentAsmnt.update();
}
};
UI Action( client)
function setState() {
var ga = new GlideAjax('sn_risk_advanced.RiskAssessmentAJAX1');
ga.addParam('sysparm_name', 'generateResponses');
ga.addParam('sysparm_currAsmtId', g_form.getUniqueValue());
ga.getXMLAnswer(function(answer) {
gsftSubmit(null, g_form.getFormElement(), 'action_name');
});
}
Please assist why the info message is coming!
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 06:12 AM
user has necessary access and correct parameters are passed through UI action. The state is getting changed successfully but still this "action not authorized" message comes.
Could you please suggest what could be the issue? Anything in the script i mentioned above?