business_rules
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| business_rules [2024/12/12 06:54] – johnsonjohn | business_rules [2024/12/13 10:04] (current) – johnsonjohn | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Business Rules | + | ======Business Rules====== |
| ---- | ---- | ||
| - | ======Project Insight Update====== | + | =====Project Insight Update===== |
| < | < | ||
| // JWJ0215 10.30.24 | // JWJ0215 10.30.24 | ||
| - | |||
| // Project Insight Update Script | // Project Insight Update Script | ||
| - | |||
| // This script will get needed data from the ServiceNow Project Request (before approved for a project), and | // This script will get needed data from the ServiceNow Project Request (before approved for a project), and | ||
| - | |||
| // push the data to Project Insight. | // push the data to Project Insight. | ||
| - | |||
| - | |||
| (function executeRule(current, | (function executeRule(current, | ||
| - | |||
| var payload = {}; | var payload = {}; | ||
| - | |||
| - | |||
| // get user from user table | // get user from user table | ||
| - | |||
| var gr = new GlideRecord(" | var gr = new GlideRecord(" | ||
| - | |||
| gr.addQuery(" | gr.addQuery(" | ||
| - | |||
| gr.query(); | gr.query(); | ||
| - | |||
| - | |||
| if (gr.next()) { | if (gr.next()) { | ||
| - | |||
| payload.requested_for = gr.email.toString(); | payload.requested_for = gr.email.toString(); | ||
| - | |||
| } | } | ||
| - | |||
| // ***End get user*** | // ***End get user*** | ||
| - | |||
| - | |||
| - | |||
| // Get Project Insight Records from the project Insight table **U_PROJECT_INSIGHT_RECORDS** | // Get Project Insight Records from the project Insight table **U_PROJECT_INSIGHT_RECORDS** | ||
| - | |||
| // get the sys id | // get the sys id | ||
| var pigr = new GlideRecord(" | var pigr = new GlideRecord(" | ||
| - | |||
| pigr.addQuery(" | pigr.addQuery(" | ||
| - | |||
| pigr.query(); | pigr.query(); | ||
| - | |||
| - | |||
| if (pigr.next()) { | if (pigr.next()) { | ||
| - | |||
| payload.u_project_insight_records_sysid = pigr.sys_id.toString(); | payload.u_project_insight_records_sysid = pigr.sys_id.toString(); | ||
| - | |||
| payload.u_project_insight_records_number = pigr.number.toString(); | payload.u_project_insight_records_number = pigr.number.toString(); | ||
| - | |||
| payload.u_prioritization_group = pigr.u_prioritization_group.toString(); | payload.u_prioritization_group = pigr.u_prioritization_group.toString(); | ||
| - | |||
| payload.priority = pigr.priority.getDisplayValue(); | payload.priority = pigr.priority.getDisplayValue(); | ||
| - | |||
| payload.u_expense = pigr.u_expense.toString(); | payload.u_expense = pigr.u_expense.toString(); | ||
| - | |||
| payload.u_project_request_status = pigr.u_project_request_status.toString(); | payload.u_project_request_status = pigr.u_project_request_status.toString(); | ||
| - | |||
| payload.short_description = pigr.short_description.toString(); | payload.short_description = pigr.short_description.toString(); | ||
| - | |||
| payload.description = pigr.description.toString(); | payload.description = pigr.description.toString(); | ||
| - | |||
| payload.u_status = pigr.u_status.toString(); | payload.u_status = pigr.u_status.toString(); | ||
| + | } | ||
| - | + | | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | } | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | | + | |
| gr = new GlideRecord(" | gr = new GlideRecord(" | ||
| - | |||
| gr.addQuery(' | gr.addQuery(' | ||
| - | |||
| gr.query(); | gr.query(); | ||
| - | |||
| - | |||
| if (gr.next()) { | if (gr.next()) { | ||
| - | |||
| gr.description.toString(); | gr.description.toString(); | ||
| - | |||
| } | } | ||
| - | |||
| - | |||
| - | |||
| gr = new GlideRecord(" | gr = new GlideRecord(" | ||
| - | |||
| gr.addQuery(" | gr.addQuery(" | ||
| - | |||
| gr.query(); | gr.query(); | ||
| - | |||
| - | |||
| if (gr.next()) { | if (gr.next()) { | ||
| - | |||
| payload.sponsor_manager_and_up_only_for_this_field = gr.email.toString(); | payload.sponsor_manager_and_up_only_for_this_field = gr.email.toString(); | ||
| - | |||
| } | } | ||
| - | |||
| - | |||
| gr = new GlideRecord(" | gr = new GlideRecord(" | ||
| - | |||
| gr.addQuery(" | gr.addQuery(" | ||
| - | |||
| gr.query(); | gr.query(); | ||
| - | |||
| - | |||
| if (gr.next()) { | if (gr.next()) { | ||
| - | |||
| payload.contact_name = gr.name.toString(); | payload.contact_name = gr.name.toString(); | ||
| - | |||
| } | } | ||
| - | |||
| - | |||
| // which_location_is_the_project_for | // which_location_is_the_project_for | ||
| - | |||
| gr = new GlideRecord(" | gr = new GlideRecord(" | ||
| - | |||
| gr.addQuery(" | gr.addQuery(" | ||
| - | |||
| gr.query(); | gr.query(); | ||
| - | |||
| - | |||
| if (gr.next()) { | if (gr.next()) { | ||
| - | |||
| payload.cost_center = gr.name.toString(); | payload.cost_center = gr.name.toString(); | ||
| - | |||
| } | } | ||
| - | |||
| - | |||
| // ***End get Project Insight Records*** | // ***End get Project Insight Records*** | ||
| - | |||
| - | |||
| - | |||
| // below information is from the **SC_REQ_ITEM** table. | // below information is from the **SC_REQ_ITEM** table. | ||
| payload.sys_id = current.sys_id.toString(); | payload.sys_id = current.sys_id.toString(); | ||
| - | |||
| payload.u_project_approved_date = current.u_project_approved_date.toString(); | payload.u_project_approved_date = current.u_project_approved_date.toString(); | ||
| - | |||
| payload.number = current.number.toString(); | payload.number = current.number.toString(); | ||
| - | |||
| payload.u_project_type = current.u_project_type.toString(); | payload.u_project_type = current.u_project_type.toString(); | ||
| - | |||
| payload.request_created_on = current.variables.request_created_on.toString(); | payload.request_created_on = current.variables.request_created_on.toString(); | ||
| - | |||
| payload.contact_s_phone_number = current.variables.contact_s_phone_number.toString(); | payload.contact_s_phone_number = current.variables.contact_s_phone_number.toString(); | ||
| + | payload.what_is_the_problem_you_are_trying_to_solve = | ||
| + | current.variables.what_is_the_problem_you_are_trying_to_solve.toString(); | ||
| + | payload.u_estimated_hours = current.u_hours.toString(); | ||
| - | | + | |
| + | var res = PI.send(payload); | ||
| - | payload.u_estimated_hours = current.u_hours.toString(); // trying u_hours | + | })(current, previous); |
| - | + | // Link | |
| + | // https://< | ||
| + | </ | ||
| - | var PI = new ProjectInsightScriptInclude(); | + | ---- |
| - | var res = PI.send(payload); | + | =====INCIDENT-Derive NonState Values from parent inc===== |
| + | < | ||
| + | // Condition: current.parent_incident.changes() && !current.parent_incident.nil() | ||
| + | (function executeRule(current, | ||
| + | // If child incident is already Closed or Cancelled, child incident should not be updated | ||
| + | if (current.incident_state == IncidentState.CLOSED || current.incident_state == IncidentState.CANCELED) | ||
| + | return; | ||
| + | |||
| + | // If parent incident is already Closed or Cancelled, child incident should not be updated | ||
| + | if (current.parent_incident.incident_state == IncidentState.CLOSED || current.parent_incident.incident_state == IncidentState.CANCELED) | ||
| + | return; | ||
| + | |||
| + | // Update child incident' | ||
| + | current.category = current.parent_incident.category; | ||
| + | current.subcategory = current.parent_incident.subcategory; | ||
| + | |||
| + | // Only copy parent incident' | ||
| + | if (!current.parent_incident.assignment_group.nil()) { | ||
| + | current.assigned_to = ''; | ||
| + | current.assignment_group = current.parent_incident.assignment_group; | ||
| + | } | ||
| - | + | // Only copy parent incident' | |
| + | if (!current.parent_incident.assigned_to.nil()) { | ||
| + | current.assigned_to = current.parent_incident.assigned_to; | ||
| + | } | ||
| })(current, previous); | })(current, previous); | ||
| - | + | </ | |
| - | // Link | + | ---- |
| + | =====INCIDENT-Display Caller Email is Empty===== | ||
| + | < | ||
| + | (function executeRule(current, | ||
| + | |||
| + | var callerName = current.caller_id.name; | ||
| + | gs.addInfoMessage(' | ||
| + | |||
| + | })(current, previous); | ||
| - | // https://< | ||
| </ | </ | ||
| + | |||
| + | ---- | ||
| + | =====True Up NonState Values from Parent INC===== | ||
| + | < | ||
| + | (function executeRule(current, | ||
| + | |||
| + | // Add your code here | ||
| + | var sysID = current.sys_id; | ||
| + | |||
| + | //Check for any child incidents | ||
| + | var childCheck = new GlideRecord(' | ||
| + | childCheck.addQuery(' | ||
| + | // | ||
| + | childCheck.query(); | ||
| + | |||
| + | if (childCheck.hasNext()) { | ||
| + | while (childCheck.next()) { | ||
| + | // If child incident is already Closed or Cancelled, child incident should not be updated | ||
| + | if (childCheck.incident_state == IncidentState.CLOSED || childCheck.incident_state == IncidentState.CANCELED) | ||
| + | return; | ||
| + | |||
| + | // Update child incident' | ||
| + | childCheck.category = current.category; | ||
| + | childCheck.subcategory = current.subcategory; | ||
| + | |||
| + | // Only copy parent incident' | ||
| + | if (!current.assignment_group.nil()) { | ||
| + | childCheck.assigned_to = ''; | ||
| + | childCheck.assignment_group = current.assignment_group; | ||
| + | } | ||
| + | |||
| + | // Only copy parent incident' | ||
| + | if (!current.assigned_to.nil()) { | ||
| + | childCheck.assigned_to = current.assigned_to; | ||
| + | } | ||
| + | |||
| + | childCheck.setWorkFlow(false); | ||
| + | childCheck.update(); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | })(current, previous); | ||
| + | |||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | =====Sys_USER-Add VIP Mark===== | ||
| + | < | ||
| + | (function executeRule(current, | ||
| + | |||
| + | //Query sys_user Table and Add VIP Mark | ||
| + | var gr = new GlideRecord(' | ||
| + | gr.addQuery(' | ||
| + | gr.query(); | ||
| + | |||
| + | while (gr.next()) { | ||
| + | gr.vip = true; | ||
| + | gr.setWorkflow(false); | ||
| + | gr.update(); | ||
| + | } | ||
| + | |||
| + | })(current, previous); | ||
| + | </ | ||
| + | |||
| + | ---- | ||
business_rules.1734015260.txt.gz · Last modified: by johnsonjohn
