task isn't generating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 06:48 PM
Hi SN experts,
I am stuck in generating task using below run script code in workflow. Requirement is, if user belongs to ABC and XYZ BU (business unit) or has email containing xyz in it then should create a ticket.
Currently ticket isn't being created for regular user but it's also not creating for given condition.
{
Please assist on this.
- Labels:
-
Cost Management (ITSM)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 09:37 PM
hi @PK14 ,
you're using name in gr21.short_description = 'xyzGmailSuspend for ' + name;, but it is not defined anywhere in the script. please define it and validate it
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 09:43 PM
Hi @Bhavya11
I missed to add it here, but that's already there in the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 09:51 PM
Hi @PK14 ,
even business_unit also because you defined it as BU
var mail = current.variables.requested_for.email;
var secondary_email = current.variables.requested_for.u_email;
var num = current.variables.requested_for.employee_number;
var title = current.variables.requested_for.title.getDisplayValue();
var manager = current.variables.requested_for.manager.getDisplayValue();
var department = current.variables.requested_for.department.getDisplayValue();
var BU = current.variables.requested_for.u_business_unit.getDisplayValue(); // Assuming you need the display value of Business Unit
var name = current.variables.requested_for.getDisplayValue(); // Assuming you need the display name
if ((BU == '036281df1b8b00108f2f0d4acd4bcbd8' ||
BU == 'cc1723c80f32070430f905cce1050ec3') &&
(mail.toLowerCase().indexOf("xyz") !== -1 ||
secondary_email.toLowerCase().indexOf("xyz") !== -1))
{
var gr21 = new GlideRecord('sc_task');
gr21.initialize();
gr21.short_description = 'xyzGmailSuspend for ' + name;
gr21.assignment_group = '6ae65e6e1b7cb5500b5c42ebbc4bcb74';
gr21.assigned_to = '';
if (secondary_email == '') {
gr21.description = 'Name: ' + name + '\n' +
'Email: ' + mail + '\n' +
'Title: ' + title + '\n' +
'Manager: ' + manager + '\n' +
'Business Unit: ' + BU + '\n' + // Updated to use BU
'Department: ' + department;
} else {
gr21.description = 'Name: ' + name + '\n' +
'Email: ' + mail + '\n' +
'Secondary Email: ' + secondary_email + '\n' +
'Title: ' + title + '\n' +
'Manager: ' + manager + '\n' +
'Business Unit: ' + BU + '\n' + // Updated to use BU
'Department: ' + department;
}
gr21.request_item = current.sys_id;
gr21.insert();
} else {
gs.info('Condition not met. No ticket created.');
}