Create meeting and modify meeting subflow trigger from business rule with complex JSON Input ServiceNow.
function executeRule(current, previous /*null when async*/ ) { if (current.contact.changes()) { try { var inputs = {}; var email = current.contact.email.toString(); var name = current.contact.name.toString(); inputs.attendees = [{ "emailAddress": { "address": email, "name": name }, "type": "required" } ]; inputs['subject'] = "test"; // String inputs['starts'] = current.window_start.toString(); inputs['ends'] = current.window_end.toString(); inputs['timezone'] = ""; // String inputs['body'] = { "Body": { "content": "meet test", "contentType": "HTML" } }; // Object // Execute Synchronously: Run in foreground. Code snippet has access to outputs. var result = sn_fd.FlowAPI.getRunner().subflow('x_g_ngr_ms_teams_g.create_meeting').inForeground().withInputs(inputs).run(); var outputs = result.getOutputs(); gs.info("outputs" + outputs); // Get Outputs: var meetings_details = outputs['meetings_details']; // Object gs.info("VTEST Full Response: " + JSON.stringify(outputs) + ". Meeting ID: " + outputs.meetings_details.id); // gs.addErrorMessage("VTEST Full Response: " + JSON.stringify(outputs) + ". Meeting ID: " + outputs.meetings_details.id); current.u_meeting_id = outputs.meetings_details.id; current.update(); } catch (ex) { var message = ex.getMessage(); gs.error(message); } } if (current.assigned_to.changes()) { try { var inputs = {}; var assignedemail = current.assigned_to.email.toString(); var assignedname = current.assigned_to.name.toString(); inputs.attendees_to_add = [{ "emailAddress": { "address": assignedemail, "name": assignedname }, "type": "required" } ]; inputs['meeting_id'] = current.u_meeting_id; // String // Execute Synchronously: Run in foreground. Code snippet has access to outputs. var result = sn_fd.FlowAPI.getRunner().subflow('x_g_ngr_ms_teams_g.modify_meeting_attendees').inForeground().withInputs(inputs).run(); var outputs = result.getOutputs(); gs.info("outputs" + outputs); // Get Outputs: // var meetings_details = outputs['meetings_details']; // Object } catch (ex) { var message = ex.getMessage(); gs.error(message); } } })(current, previous);
Create meeting and modify meeting subflow trigger with complex JSON Input ServiceNow.
Working Code Asked question February 29, 2024