- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 02:25 AM - edited 01-09-2023 02:26 AM
I have a requirement called Display Pop-up Message in Incident Form.
1. I have created a customized field called 'User Contacted'(String) on the Incident form and this field has choices (Phone, Email, Chat).
2. 'User Contacted' field should display only for Service Desk group members, also when the assignment group is Service Desk even if the Logged in belongs to Service Desk 'User Contacted' field should not be visible on the Incident form. The field should be visible only when the assignment group doesn't belong to the Service Desk.
3. 'User Contacted' field should Display only when the Incident form Loads, when the form loads the pop-up should come and if they are selecting the choice from the pop-up the same value should update in the 'User Contacted' in the Incident form.
4. When the State is InProgress - 'Assigned to' is Mandatory After the Assignment group changes, this should be mandatory while saving the form from the pop-up.
Any help much be appreciated, thank you.
Regards,
Pavan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 02:51 AM
Hi Pavan,
First Create UI Page for this by using the below code:
HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<table>
<tr>
<td style="width:25%">
<g:form_label>
Select Contact Type:
</g:form_label>
</td>
<td style="width:60%">
<g:ui_choicelist name="User_Contacted" id="User_Contacted" table="incident" mandatory="true" field="u_user_contacted" query="active=true"/>
</td>
</tr>
<tr>
<td>
<g:dialog_buttons_ok_cancel ok_id="submitData" ok="return continueOK()" ok_type="button" ok_text="${gs.getMessage('Okay')}" ok_style_class="btn btn-primary"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script:
function continueOK() {
var gdw = GlideDialogWindow.get();
var user = gel('User_Contacted').value;
var sys_id = gdw.getPreference('sys_id'); //get the values passed in the client script
var selected_value = gdw.getPreference('value'); //get the values passed in the client script
g_form.setValue("u_user_contacted", user);
g_form.setMandatory("assigned_to", false);
GlideDialogWindow.get().destroy();
}
Processing Script:
var user = 'User_Contacted'.value;
{
var inc = new GlideRecord("incident");
inc.get('sys_id',current.sys_id);
inc.setValue('u_user_contacted', user);
inc.insert();
}
Now you can Create Script Include for your second point:
var UserContactedSD = Class.create();
UserContactedSD.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserMembership: function() {
if (gs.getUser().isMemberOf('sys_id')) //sys_id of the ServiceDesk Group
return "hide";
else return "no-hide";
},
type: 'UserContactedSD'
});
Now you can 'create 2 OnLoad Client Scripts' to achieve this requirement:
1st Client Script:
function onLoad() {
//Type appropriate comment here, and begin script below
var cat = new GlideAjax("UserContactedSD");
cat.addParam("sysparm_name", 'getUserMembership');
cat.getXML(UserContactedSD);
function UserContactedSD(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'hide' && g_form.getValue('assignment_group') != 'sys_id of servicedesk group' ) {
g_form.setVisible('u_user_contacted', true);
}
else {
g_form.setVisible('u_user_contacted', false);
}
}
}
2nd Client Script:
function onLoad() {
//Type appropriate comment here, and begin script below
var cat = new GlideAjax("UserContactedSD");
cat.addParam("sysparm_name", 'getUserMembership');
cat.getXML(UserContactedSD);
function UserContactedSD(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'hide' && g_form.getValue('assignment_group') != 'sys_id of servicedesk group' ) {
var dialog = new GlideDialogWindow('User Contacted'); //Mention your UI Page name here
dialog.setTitle('User Contacted'); //Set the dialog title
dialog.setSize(650, 600); //Set the dialog size
dialog.render(); //Open the dialog
}
}
}
Please implement this in your PDI Instance first and check, if it meets your requirement you can implement the same in your Instance.
Please hit like/Accept as solution if it works for you.
Thanks,
Harish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 02:51 AM
Hi Pavan,
First Create UI Page for this by using the below code:
HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<table>
<tr>
<td style="width:25%">
<g:form_label>
Select Contact Type:
</g:form_label>
</td>
<td style="width:60%">
<g:ui_choicelist name="User_Contacted" id="User_Contacted" table="incident" mandatory="true" field="u_user_contacted" query="active=true"/>
</td>
</tr>
<tr>
<td>
<g:dialog_buttons_ok_cancel ok_id="submitData" ok="return continueOK()" ok_type="button" ok_text="${gs.getMessage('Okay')}" ok_style_class="btn btn-primary"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script:
function continueOK() {
var gdw = GlideDialogWindow.get();
var user = gel('User_Contacted').value;
var sys_id = gdw.getPreference('sys_id'); //get the values passed in the client script
var selected_value = gdw.getPreference('value'); //get the values passed in the client script
g_form.setValue("u_user_contacted", user);
g_form.setMandatory("assigned_to", false);
GlideDialogWindow.get().destroy();
}
Processing Script:
var user = 'User_Contacted'.value;
{
var inc = new GlideRecord("incident");
inc.get('sys_id',current.sys_id);
inc.setValue('u_user_contacted', user);
inc.insert();
}
Now you can Create Script Include for your second point:
var UserContactedSD = Class.create();
UserContactedSD.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserMembership: function() {
if (gs.getUser().isMemberOf('sys_id')) //sys_id of the ServiceDesk Group
return "hide";
else return "no-hide";
},
type: 'UserContactedSD'
});
Now you can 'create 2 OnLoad Client Scripts' to achieve this requirement:
1st Client Script:
function onLoad() {
//Type appropriate comment here, and begin script below
var cat = new GlideAjax("UserContactedSD");
cat.addParam("sysparm_name", 'getUserMembership');
cat.getXML(UserContactedSD);
function UserContactedSD(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'hide' && g_form.getValue('assignment_group') != 'sys_id of servicedesk group' ) {
g_form.setVisible('u_user_contacted', true);
}
else {
g_form.setVisible('u_user_contacted', false);
}
}
}
2nd Client Script:
function onLoad() {
//Type appropriate comment here, and begin script below
var cat = new GlideAjax("UserContactedSD");
cat.addParam("sysparm_name", 'getUserMembership');
cat.getXML(UserContactedSD);
function UserContactedSD(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'hide' && g_form.getValue('assignment_group') != 'sys_id of servicedesk group' ) {
var dialog = new GlideDialogWindow('User Contacted'); //Mention your UI Page name here
dialog.setTitle('User Contacted'); //Set the dialog title
dialog.setSize(650, 600); //Set the dialog size
dialog.render(); //Open the dialog
}
}
}
Please implement this in your PDI Instance first and check, if it meets your requirement you can implement the same in your Instance.
Please hit like/Accept as solution if it works for you.
Thanks,
Harish.