how to make a field read only using ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 04:22 AM
Hi,
I have a requirement where i need to create the "assign to me" button on interaction form, when some user clicks that button , then the interaction should get assign to him & the "assigned to" field should become read only.
The interaction is getting assigned correctly, but when i try to add read only code then it is not working.
Below is the code:
show insert is true
show update is true
form button is true
condition: current.active==true &&gs.getUser().isMemberOf(current.assignment_group)
script :
current.assigned_to = gs.getUserID();
current.update();
action.setRedirectURL(current);
how to ensure that the interaction gets assigned when button is clicked & the assigned to field become read only?
Kindly, help!
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2022 12:23 AM
Hi @SK41
You can try this method
//Client check box true
function assignTicket() {
var ga = new GlideAjax('validateUserGroup');
ga.addParam('sysparm_name', 'validateGroup');
ga.addParam('sysparm_grp', g_form.getValue('assignment_group'));
ga.getXMLAnswer(getResponse);
function getResponse(answer) {
if (answer == 'false' || answer==false) {
alert('User is not part of assignment group');
return false;
} else {
g_form.setValue('assigned_to', g_user.userID);
g_form.setReadOnly('assigned_to', true);
gsftSubmit(null, g_form.getFormElement(), 'assign_ticket');
}
}
}
//script include
var validateUserGroup = Class.create();
validateUserGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
validateGroup: function() {
var group = this.getParameter('sysparm_grp');
gs.addInfoMessage(group);
if (gs.getUser().isMemberOf(group)) {
return true;
} else {
return false;
}
},
type: 'validateUserGroup'
});