Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

code transfer

Shaik Imran
Tera Contributor
<table style="width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; border: 1px solid rgb(136, 136, 140);">
  <tbody>
    <!-- Table Title -->
    <tr>
      <td colspan="2" style="background-color: rgb(126, 128, 126); color: white; font-size: 1.5em; font-weight: bold; padding: 8px; border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 15.0pt;">Critical Incident Communication</span>
      </td>
    </tr>
    <!-- Priority Banner -->
    <tr>
      <td colspan="2" style="background-color: ${mail_script:im_cic_priority_color}; color: ${mail_script:im_cic_priority_textcolor}; font-weight: bold; padding: 4px; border: 1px solid #88888c; border-top: none;">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">Priority ${mail_script:im_cic_priority}</span>
      </td>
    </tr>
    <!-- Incident hyperlink (WHITE row, no shading) -->
    <tr>
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140); padding: 4px;">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">${URI_REF}</span>
      </td>
    </tr>
    <!-- Priority (gray row) -->
    <tr style="background-color: rgb(201, 201, 201);">
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
          <span style="font-weight: bold;">Priority:</span> ${priority}
        </span>
      </td>
    </tr>
    <!-- Start (white row) -->
    <tr>
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
          <span style="font-weight: bold;">Start:</span> ${u_outage_start}
        </span>
      </td>
    </tr>
    <!-- Resolved (gray row) -->
    <tr style="background-color: rgb(201, 201, 201);">
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
          <span style="font-weight: bold;">Resolved:</span> ${u_outage_end}
        </span>
      </td>
    </tr>
    <!-- Duration (white row) -->
    <tr>
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
          <span style="font-weight: bold;">Duration:</span> ${mail_script:im_cic_duration}
        </span>
      </td>
    </tr>
    <!-- Systems Impacted (gray row) -->
    <tr style="background-color: rgb(201, 201, 201);">
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
          <span style="font-weight: bold;">Systems Impacted:</span> ${mail_script:im_cic_getAffectedProducts}
        </span>
      </td>
    </tr>
    <!-- Description (white row) -->
    <tr>
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
          <span style="font-weight: bold;">Description:</span> ${u_cic_description}
        </span>
      </td>
    </tr>
    <!-- Impact to Clients (gray, full width) -->
    <tr style="background-color: rgb(201, 201, 201);">
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
          <span style="font-weight: bold;">Impact to our Clients:</span> ${u_external_impact}
        </span>
      </td>
    </tr>
    <!-- Impact to Employees (white, full width) -->
    <tr>
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
          <span style="font-weight: bold;">Impact to our Employees:</span> ${u_internal_impact}
        </span>
      </td>
    </tr>
    <!-- Cause (gray, full width) -->
    <tr style="background-color: rgb(201, 201, 201);">
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
          <span style="font-weight: bold;">Cause:</span> ${u_probable_cause}
        </span>
      </td>
    </tr>
    <!-- Completed Actions (white, full width) -->
    <tr>
      <td colspan="2" style="border: 1px solid rgb(136, 136, 140);">
        <span style="font-family: Aptos, sans-serif; font-size: 12.0pt;">
          <span style="font-weight: bold;">Completed Actions<br></span> ${u_previous_activities}
        </span>
      </td>
    </tr>
  </tbody>
</table>
13 REPLIES 13

Deepak Shaerma
Kilo Sage
Kilo Sage

Hi @Shaik Imran 

Could you please explain a liitle bit about your requirement??

Happy to help! If this resolved your issue, kindly mark it as the correct answer   and Helpful and close the thread 🔒 so others can benefit too.

Warm Regards,

Deepak Sharma

Community Rising Star 2025

Shaik Imran
Tera Contributor

Certainly! Here’s a comprehensive view of each user story, enhanced and aligned with the context of your attached table. For each story, you’ll find:

  • Short Description
  • Detailed Description
  • Enhanced Acceptance Criteria
  • Enhanced Developer Notes (including: which methods/ServiceNow/Jira features to use, step-by-step “how to proceed,” dependencies, and who typically supplies/approves API details)

1. Story Creation

Short Description:
Enable automatic creation of a linked Jira story whenever a ServiceNow (SN) story is created, to synchronize both systems for seamless cross-team collaboration.

Detailed Description:
As a Product Owner, I want a new ServiceNow story to automatically create a corresponding Jira story—using mapped project fields—so both ITSM and development teams operate from a unified backlog with traceable cross-references.

Enhanced Acceptance Criteria:

  • Creating a SN story calls an integration that creates a mapped Jira story in the correct board/project.
  • The Jira issue key is written to a custom field in the originating SN record.
  • All integration/API errors (including mapping issues) are logged in a tech audit table and admins are notified (via system notification or email).
  • API field mappings and project/board selections must use a configurable mapping table reviewed by the PM.
  • No manual steps required for normal operation—failures should be visible and easy to escalate.

Developer Notes:

  • Method:
    • Use ServiceNow Flow Designer triggered on “Record Created” (not business rules for maintainability).
    • Use IntegrationHub “REST” step to call Jira REST API: POST /rest/api/2/issue
    • Dynamic field/project selection via a custom ServiceNow mapping table (maintained by PM/product owner).
    • Flow should handle response parsing (extract Jira key, update SN record) and log integration errors (write to custom log table/subflow).
  • How to proceed:
    1. Work with Product Manager (PM) for mapping table format and board/project mappings.
    2. Build/test Flow Designer integration, using a non-production Jira instance or test project.
    3. API credential ownership: Work with ServiceNow/Jira admins to configure secure OAuth2/application link for REST calls.
    4. Define log/audit structure; set up admin notification (contact SN admin for email/slack integration setup).
  • Who provides API details:
    • The Jira admin provides API endpoints, available fields, authentication keys, and field IDs.
    • The ServiceNow integration team owns SN-side configuration, mapping logic, and manages the credential vault.

2. Story Update

Short Description:
Synchronize mapped story updates in ServiceNow to their linked Jira stories, ensuring information parity across platforms.

Detailed Description:
As a Product Owner, I want updates to mapped fields in ServiceNow stories to be pushed automatically to their linked Jira stories, keeping everyone aligned and minimizing manual corrections.

Enhanced Acceptance Criteria:

  • Only updates to mapped/configured fields in SN trigger push to Jira.
  • Only those fields are synced; others are ignored.
  • Each successful sync is logged and timestamped in SN.
  • On integration errors, retries are performed (as defined), and unresolved failures alert admins.
  • No unmapped fields are pushed to Jira; extraneous changes are ignored.

Developer Notes:

  • Method:
    • Setup Flow Designer “Record Updated” on the SN story table, filtered for mapped fields.
    • Use IntegrationHub “REST” step with Jira’s PUT /rest/api/2/issue/{issueKey} endpoint.
    • Sync log/audit table for every update attempt (status, timestamp, error codes).
    • Subflows for error handling and retry (exponential backoff if possible; max attempts as per admin).
    • Check mapping table for which fields are updateable.
  • How to proceed:
    1. PM/business analysts finalize the mapping table (priority fields, update logic).
    2. Build and unit-test update integrations in lower SN environment.
    3. Admins coordinate test approval and credential management for SN/Jira test accounts.
    4. Review and document field update scenarios with development and SN/Jira admin teams.
  • Who provides API details:
    • Jira admin (for field keys, REST permissions, endpoint config).
    • ServiceNow admin (for field availability, Flow Designer/IntegrationHub licensing).

3. Jira → SN Story

Short Description:
Auto-create a ServiceNow story when a new Jira story is created, ensuring ITSM teams are in sync with development activity.

Detailed Description:
As a Jira user, when a new story is created in Jira, I want a corresponding ServiceNow story to be created automatically—following field and assignment group mappings—so nothing falls through the cracks between systems.

Enhanced Acceptance Criteria:

  • A Jira webhook (issue created event) POSTs to a secure SN Scripted REST API endpoint.
  • ServiceNow parses the payload, applies mapping logic, and creates a story, referencing Jira issue key and mapped assignment group.
  • Any creation errors are logged and visible to admins; duplicate SN stories from the same Jira issue are prevented (unique constraint).
  • Successful creations log the Jira key in the SN record.

Developer Notes:

  • Method:
    • Configure a Jira webhook (issue created) targeting a custom Scripted REST API in SN.
    • SN side: Parse and validate incoming data, check for existing SN stories with the same Jira key to avoid duplicates, map fields from payload using SN mapping table, and create the SN story.
    • Handle errors/logging in SN (custom table); notify admins as required.
  • How to proceed:
    1. Define JSON contract with Jira admin; decide on secure auth (API token/IP allowlist).
    2. Configure webhook and test via postman/curl before going live.
    3. Ensure mapping table is maintained by PM/team lead and up to date.
    4. Validate failure/duplicate scenarios are logged, and that admin notifications are solid.
  • Who provides API details:
    • Jira admin: webhook event and payload details, endpoint config, auth.
    • ServiceNow developer/admin: provides SN Scripted REST API and field mapping logic.

4. Initiative Tracker

Short Description:
Auto-create a Jira Epic for every new ServiceNow SIT Initiative/Epic, ensuring portfolio-level alignment.

Detailed Description:
As an Initiative Manager, I want each new ServiceNow SIT Initiative to trigger automatic creation of a linked Jira Epic (with mapped fields/owners), so that strategic work is coordinated and related work items can be associated across systems.

Enhanced Acceptance Criteria:

  • Creating an SN SIT Initiative/epic record fires a flow that creates a mapped Jira Epic.
  • The Jira Epic key/url is stored in the SN record for traceability.
  • If the SIT Initiative is associated with an unmapped project, the creation is blocked, an error code is logged, and the admin is alerted (no create attempts without a valid mapping).
  • Deleting an SN Initiative does not delete the related Jira Epic.
  • Creation events and errors are recorded in an audit log.

Developer Notes:

  • Method:
    • Flow Designer “Record Created” on the SN Initiative/Epic table.
    • IntegrationHub “REST” step to create an epic via Jira POST /rest/api/2/issue (type=Epic).
    • Mapping table logic per Adam/PM’s review.
    • Log/create error tickets when mapping not found or API failure occurs.
    • Admin notifications via system/email or SN workflow.
  • How to proceed:
    1. Stakeholders (PM, Adam) finalize mapping and field requirements for Epics.
    2. Build/test creation logic in dev/sandbox first.
    3. Validate error handling works for unmapped projects.
    4. Confirm security/auth concerns for IntegrationHub/REST steps.
  • Who provides API details:
    • Jira admin: required Epic fields, custom field keys, permissions.
    • PM/Business Owner: mapping table entries, routing rules.
    • SN admin: API config, endpoint, and workflow validation.

5. Tasks/Subtasks Sync

Short Description:
Bi-directional sync of ServiceNow and Jira tasks/subtasks, maintaining hierarchy and status between systems.

Detailed Description:
As a Scrum Team Member, I want all service tasks/subtasks in ServiceNow to have bi-directional sync with Jira (including parent/child linkage, updates), so detailed work visibility is always in sync.

Enhanced Acceptance Criteria:

  • When a SN task/subtask is created, a corresponding item is created in Jira with parent-child structure.
  • Updates to Jira subtasks propagate back to SN with mapped fields updated.
  • All sync events (create/update) are logged centrally with success/error state and timestamp.
  • No automatic deletion: only explicit admin actions can trigger deletions.
  • All mapping or process errors trigger admin alerts.

Developer Notes:

  • Method:
    • Flow Designer “Record Created/Updated” in SN for tasks/subtasks.
    • Jira: If webhooks support subtask events, use them; otherwise, implement an API polling process (REST GET / updated > last sync).
    • Maintain parent/child keys via SN mapping table.
    • Update audit log on every cross-system create/update attempt.
    • Provide admin interface for error log review and manual resolution of sync failures.
  • How to proceed:
    1. Define/scope the mapping table for task/subtask types, statuses, and parent-child relationships.
    2. Build/test in isolated sandbox with mocked parent/child combinations.
    3. Review sync logic with SN/Jira admins—especially for bi-directional updates and conflict handling.
    4. Plan administrator training and escalation support for difficult mapping errors.
  • Who provides API details:
    • Jira admin: task and subtask REST endpoints, parent/child implementation, webhook support.
    • SN admin/developer: task/subtask table setup, field mapping.

Who Provides API Details?

  • Jira admin:

    • Supplies API endpoint URLs
    • Provides required/requested field names & custom fields
    • Manages and supplies integration credentials (tokens, OAuth, app links)
    • Sets up webhooks/events as needed
  • ServiceNow admin/developer:

    • Provides REST API endpoints for inbound calls
    • Maintains IntegrationHub/Flow Designer logic
    • Coordinates and secures mapping table with the PM/Product Owner
  • Product Owner/PM:

    • Finalizes field/project mapping definitions
    • Approves project/assignment group mappings and mapping owners
  • Business/Initiative Manager (for initiatives/epics):

    • Reviews mapping of high-level work items and their required fields

If you need an example mapping table layout, field mapping document, or specific API request/response samples for your environment, let me know!
Here’s a detailed breakdown for each story, now including who typically provides the API details for each integration:

1. Story Creation

Short Description:
Enable automatic creation of a linked Jira story whenever a ServiceNow story is created.

Description:
As a Product Owner, I want new ServiceNow stories to automatically sync and create corresponding Jira stories using mapped fields so cross-system teams stay aligned.

Enhanced Acceptance Criteria:

  • New SN story triggers Jira creation (correct board/project via mapping table).
  • SN stores Jira issue key for tracking.
  • All communication errors are logged/audited and alert admins.
  • Configurable mapping table governs field/project board selections; no manual routine intervention.

Developer Notes:

  • Method: ServiceNow Flow Designer “Record Created” trigger.
  • Use IntegrationHub REST step to POST to Jira /rest/api/2/issue.
  • Query mapping table for fields/project.
  • On success: parse Jira key, update SN story. On failure: log and alert admin (subflow).
  • API Details Provided By:
    • Jira Admins: Endpoint URLs, authentication details, field metadata/IDs.
    • SN Admins: Table/flow details, credential handling.
    • PM: Mapping table, field/board relationships.

2. Story Update

Short Description:
Keep SN and Jira stories aligned by pushing mapped updates from SN to Jira.

Description:
As a Product Owner, I want mapped field changes in ServiceNow stories to automatically update their linked Jira stories.

Enhanced Acceptance Criteria:

  • Only mapped fields trigger update to Jira.
  • Successful syncs timestamped in SN.
  • Retry logic and admin escalation on repeated failure.
  • No unmapped field overwrites.

Developer Notes:

  • Method: ServiceNow Flow Designer “Record Updated” (field filter).
  • Use IntegrationHub REST step with Jira PUT /rest/api/2/issue/{issueKey}.
  • Sync log with status/timestamp.
  • Error/retry subflows.
  • API Details Provided By:
    • Jira Admins: Modifiable fields list, endpoint configs.
    • SN Admins: Field filtering in flow, credentials.

3. Jira → SN Story

Short Description:
Automatically generate SN story on new Jira story creation.

Description:
As a Jira user, I want a Jira webhook to create SN stories so nothing is missed.

Enhanced Acceptance Criteria:

  • Jira webhook calls SN REST endpoint.
  • SN story references Jira key, uses mapping table for assignment group.
  • Duplicate prevention (unique Jira key check) in SN.
  • All failures logged/audited.

Developer Notes:

  • Method:
    • Jira webhook to SN Scripted REST API (secured by OAuth/token or IP whitelisting).
    • REST API parses, maps, validates, and creates SN story, storing Jira issue link.
    • Error/duplicate handling integrated.
  • API Details Provided By:
    • Jira Admins: Webhook payload config, credentials, supported projects.
    • SN Admins: REST endpoint, authentication method, mapping logic.

4. Initiative Tracker

Short Description:
Auto-create Jira Epic for new SN SIT Initiatives/Epics.

Description:
As an Initiative Manager, I want SN SIT Initiatives to always result in mapped Jira Epics for portfolio tracking.

Enhanced Acceptance Criteria:

  • SN initiative triggers Epic creation in Jira (mapping-validated).
  • SN records store the Jira Epic key/reference.
  • Unmapped projects result in error/no Epic in Jira, and admin notification.
  • Deletion does not cascade from SN to Jira.

Developer Notes:

  • Method:
    • Flow Designer “Record Created” on Epic/Initiative table.
    • REST call to Jira (Epic type), mapping checked in SN.
    • Error handling and admin notification if mapping missing.
  • API Details Provided By:
    • Jira Admins: Epic creation fields/requirements.
    • PM/Adam: Mapping table content/updates.
    • SN Admins: Flow logic, error notification.

5. Tasks/Subtasks Sync

Short Description:
Bi-directional sync of SN and Jira tasks/subtasks with linkage.

Description:
As a Scrum Team Member, I want all SN tasks/subtasks synced so both systems reflect up-to-date detail.

Enhanced Acceptance Criteria:

  • SN task/subtask creation triggers Jira item creation (with parent-child linkage).
  • Jira subtask updates push mapped changes to SN.
  • All events and errors logged with admin alerts on failure.
  • No automated deletions—admin intervention only.

Developer Notes:

  • Method:
    • Flow Designer “Record Created/Updated” (SN); Jira webhooks/polling for external updates.
    • REST calls for creation/update; parent-child links maintained per mapping table.
    • Logging and admin review panels for errors and manual deletion triggers.
  • API Details Provided By:
    • Jira Admins: Task/subtask REST details, webhook options, parent linkage fields.
    • SN Admins: Flow/table, mapping, credentials.

Summary Table of API Detail Providers

Story API Details Provided By

If you need an example of a mapping table template or specific payload details for story creation/update, just let me know!

Shaik Imran
Tera Contributor
(function executeRule(current, previous /*null when async*/ ) {
    // Variables to keep track of whether specific tasks have been created
    var alertTaskCreated = false;
    var resiliencyTaskCreated = false;
    var businessTaskCreated = false;
    var scheprop = gs.getProperty('cf.change.8-5schedule.lead_time_calc');

    var gr_problem_task_check = new GlideRecord('problem_task');
    gr_problem_task_check.addQuery('problem', current.sys_id.toString());
    gr_problem_task_check.query();

    // Check if either of the tasks below exist in this problem's tasks
    while (gr_problem_task_check.next()) {
        // Alerting / Monitoring problem task

        if (gr_problem_task_check.getValue('short_description') == "Business Risk & Controls Technology Team review") {
            businessTaskCreated = true;
        }
        if (gr_problem_task_check.getValue('u_category') == "Business Risk and Controls") {
            businessTaskCreated = true;
        }
        if (gr_problem_task_check.getValue('short_description') == "Determine if monitoring and/or alerting should be modified and/or created") {
            alertTaskCreated = true;
        }
        // Resiliency problem task
        if (gr_problem_task_check.getValue('short_description') == "Perform a third-party resiliency review") {
            resiliencyTaskCreated = true;
        }

    }

    // Create the Alerting / Monitoring Task
    if (!businessTaskCreated) {
        var due_date = new GlideDate();
        var dura = new GlideDuration(60 * 60 * 9 * 1000 * 30);
        var glides = new GlideSchedule(scheprop);
        var end = glides.add(due_date, dura);

        var arr_date = [];
        arr_date = end.toString().split(' ');
        //due_date.setDisplayValue(arr_date[0] + ' 17:00:00', 'yyyy-MM-dd HH:mm:ss');
        var end_date = arr_date[0] + ' 17:00:00';


        var gr_problem_task_business = new GlideRecord('problem_task');
        gr_problem_task_business.initialize();
        gr_problem_task_business.setValue('cmdb_ci', current.getValue('cmdb_ci'));
        gr_problem_task_business.setValue('assignment_group', "6fa377e0c37be210332ebe0bb00131d1");
        gr_problem_task_business.setValue('problem', current.sys_id.toString());
        gr_problem_task_business.setValue('state', 2);
        gr_problem_task_business.setValue('short_description', "Business Risk & Controls Technology Team review");
        gr_problem_task_business.setValue('description', "Business Risk & Controls Technology Team review for TLA.");
        gr_problem_task_business.setValue('priority', 2);
        gr_problem_task_business.setValue('due_date', end_date.toString());
        gr_problem_task_business.setValue('u_category', "Business Risk and Controls");
        gr_problem_task_business.insert();
    }

    // Create the Alerting / Monitoring Task
    if (!alertTaskCreated) {
        var due_date_alert = new GlideDateTime();
        due_date_alert.addDaysUTC(15);

        var arr_date_alert = [];

        arr_date_alert = due_date_alert.toString().split(' ');
        due_date_alert.setDisplayValue(arr_date_alert[0] + ' 17:00:00', 'yyyy-MM-dd HH:mm:ss');

        //STRY0284553 Edits - Changing Moogsoft CI sys_id to ServiceNow Event Management CI sys_id
        // var gr_cmdb_ci = new GlideRecord('cmdb_ci');
        // gr_cmdb_ci.get('4953c4201b9ac6d431f70d45604bcbb1'); // sys_id for SERVICENOW EVENT MANAGEMENT CI

        // var gr_sys_user_group = new GlideRecord('sys_user_group');
        // gr_sys_user_group.get('f9cbe5511396ae00570876d66144b054'); // sys_id for Enterprise Monitoring and Alerting group

        var gr_problem_task = new GlideRecord('problem_task');
        gr_problem_task.initialize();
        // gr_problem_task.cmdb_ci = gr_cmdb_ci.sys_id.toString();
        // gr_problem_task.assignment_group = gr_sys_user_group.sys_id.toString();
        gr_problem_task.setValue('cmdb_ci', current.getValue('cmdb_ci'));
        gr_problem_task.setValue('assignment_group', current.getValue('assignment_group'));
        gr_problem_task.setValue('problem', current.sys_id.toString());
        gr_problem_task.setValue('state', 2);
        gr_problem_task.setValue('short_description', "Determine if monitoring and/or alerting should be modified and/or created");
        gr_problem_task.setValue('description', "Determine if monitoring and/or alerting should be modified and/or created.");
        gr_problem_task.setValue('due_date', due_date_alert.toString());
        gr_problem_task.setValue('u_category', "Alerting/Monitoring");
        gr_problem_task.insert();
    }

    // Create the Third-Party Resiliency Review task
    // Cause Code must start with Vendor
    if (!resiliencyTaskCreated && current.u_cause_code.u_code.indexOf('Vendor') == 0) {

        // Create due date 30 days from now at 17:00
        var due_date_1 = new GlideDateTime();
        due_date_1.addDaysUTC(30);
        var arr_date_1 = [];
        arr_date_1 = due_date_1.toString().split(' ');
        due_date_1.setDisplayValue(arr_date_1[0] + ' 17:00:00', 'yyyy-MM-dd HH:mm:ss');

        // Set assignment group to Business Continuity Management QA (sys_id below)
        //STRY0284553 Edits - Changing Assignment Group to Business Continuity Management QA Assignment Group
        var gr_sys_user_group = new GlideRecord('sys_user_group');
        gr_sys_user_group.get('09f055cb1b7ae1d49cb2657a234bcb72');

        // Create the new problem task record
        var gr_problem_task_resilance = new GlideRecord('problem_task');
        gr_problem_task_resilance.initialize();
        gr_problem_task_resilance.setValue('cmdb_ci', current.getValue('cmdb_ci'));
        gr_problem_task_resilance.setValue('assignment_group', gr_sys_user_group.sys_id.toString());
        gr_problem_task_resilance.setValue('problem', current.sys_id.toString());
        gr_problem_task_resilance.setValue('state', 2);
        gr_problem_task_resilance.setValue('short_description', "Perform a third-party resiliency review");
        gr_problem_task_resilance.setValue('description', "Perform a third-party resiliency review for TLA.");
        gr_problem_task_resilance.setValue('due_date', due_date_1.toString());
        gr_problem_task_resilance.setValue('u_category', "Business Continuity/Disaster Recovery Plan");
        gr_problem_task_resilance.insert();
    }

})(current, previous);
 
ShaikImran_0-1764153070129.png

 

Shaik Imran
Tera Contributor

 

(function executeRule(current, previous /*null when async*/) {

    // Unique descriptions for each type
    var TASKS = [
        {
            short_description: "Business Risk & Controls Technology Team review",
            u_category: "Business Risk and Controls",
            assignment_group: "6fa377e0c37be210332ebe0bb00131d1",
            description: "Business Risk & Controls Technology Team review for TLA.",
            priority: 2,
            due_days: 30
        },
        {
            short_description: "Determine if monitoring and/or alerting should be modified and/or created",
            u_category: "Alerting/Monitoring",
            assignment_group: current.getValue('assignment_group'), // Use current assignment group
            description: "Determine if monitoring and/or alerting should be modified and/or created.",
            priority: null, // Use default
            due_days: 15
        }
    ];

    // Always check and create the Business Risk/Alerting tasks
    TASKS.forEach(function(task) {
        var gr_check = new GlideRecord('problem_task');
        gr_check.addQuery('problem', current.getUniqueValue());
        gr_check.addQuery('short_description', task.short_description);
        gr_check.query();
        if (!gr_check.hasNext()) {
            // Set due date at 17:00 of due_days ahead
            var due_date = new GlideDateTime();
            due_date.addDaysUTC(task.due_days);
            var date_parts = due_date.toString().split(' ');
            due_date.setDisplayValue(date_parts[0] + ' 17:00:00', 'yyyy-MM-dd HH:mm:ss');

            var gr_task = new GlideRecord('problem_task');
            gr_task.initialize();
            gr_task.setValue('cmdb_ci', current.getValue('cmdb_ci'));
            gr_task.setValue('assignment_group', task.assignment_group);
            gr_task.setValue('problem', current.getUniqueValue());
            gr_task.setValue('state', 2);
            gr_task.setValue('short_description', task.short_description);
            gr_task.setValue('description', task.description);
            if (task.priority) {
                gr_task.setValue('priority', task.priority);
            }
            gr_task.setValue('due_date', due_date.toString());
            gr_task.setValue('u_category', task.u_category);
            gr_task.insert();
        }
    });

    // Third-Party Resiliency Review task: only if not present *and* cause code starts with 'Vendor'
    if (current.u_cause_code && current.u_cause_code.u_code.indexOf('Vendor') === 0) {
        var resiliency_desc = "Perform a third-party resiliency review";
        var gr_check_res = new GlideRecord('problem_task');
        gr_check_res.addQuery('problem', current.getUniqueValue());
        gr_check_res.addQuery('short_description', resiliency_desc);
        gr_check_res.query();
        if (!gr_check_res.hasNext()) {
            var due_date_res = new GlideDateTime();
            due_date_res.addDaysUTC(30);
            var date_parts_res = due_date_res.toString().split(' ');
            due_date_res.setDisplayValue(date_parts_res[0] + ' 17:00:00', 'yyyy-MM-dd HH:mm:ss');

            var gr_assignment_group = new GlideRecord('sys_user_group');
            gr_assignment_group.get('09f055cb1b7ae1d49cb2657a234bcb72');

            var gr_task_res = new GlideRecord('problem_task');
            gr_task_res.initialize();
            gr_task_res.setValue('cmdb_ci', current.getValue('cmdb_ci'));
            gr_task_res.setValue('assignment_group', gr_assignment_group.getUniqueValue());
            gr_task_res.setValue('problem', current.getUniqueValue());
            gr_task_res.setValue('state', 2);
            gr_task_res.setValue('short_description', resiliency_desc);
            gr_task_res.setValue('description', "Perform a third-party resiliency review for TLA.");
            gr_task_res.setValue('due_date', due_date_res.toString());
            gr_task_res.setValue('u_category', "Business Continuity/Disaster Recovery Plan");
            gr_task_res.insert();
        }
    }
})(current, previous);