I have an run script in workflow which creates an ritm, i need to convert it to flow, Can someone?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 04:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 05:28 AM
what do you mean by log the activity?
how are you planning to trigger the flow?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 05:08 AM
Hi,
You can call a subflow that first performs the logging as needed, and then submits the Request as per suggestion by Ankur.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 05:34 AM
Hi @Harithapola
I found a holistic PDF that will help.
PFA
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 09:56 AM
Hi @Ravi Gaurav ,
Thanks for it and could you please help me understand after 5 sec of wait time, how do we update the newly created ritm(through flow action)
I have the below script in update DB run script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2025 08:06 AM
Hi @Ravi Gaurav
I tried your solution from the pdf but its creating new ritm with new request number instead of creating with same request. Please find code below.
(function execute(inputs, outputs) { gs.log('#### Flow Action: Create Database Security - Distributed RITM; inputs.number = ' + inputs.number); try { var catItem = "6a279c080fbd2200471ce498b1050e02"; // database security distributed Catalog Item sys_id var secFormType = inputs.u_request_type.toString(); var requestedFor; if (secFormType === 'New Hire') { requestedFor = inputs.u_multiple_users.toString(); } else { requestedFor = inputs.numusersMultipleUsers.toString(); } var cartid = gs.generateGUID(); var cart = new sn_sc.CartJS(cartid); var request = { 'sysparm_id': catItem, 'sysparm_quantity': '1', 'sysparm_cart_name': cartid, 'sc_request':inputs.existingRequestSysId, 'variables': { 'secFormType': secFormType, 'newhireHiringManager': inputs.newhireHiringManager.toString(), 'transferNewManager': inputs.transferNewManager.toString(), 'chkModal': inputs.chkModal.toString(), 'numusersUsersType': inputs.numusersUsersType.toString(), 'chkBotAccount': inputs.chkBotAccount.toString(), 'botAccount': inputs.botAccount.toString(), // 'numusersMultipleUsers': inputs.numusersMultipleUsers.toString(), 'userLandIDs': inputs.userLandIDs.toString(), 'effDate': inputs.effDate.toString(), 'chkBotEnabled': inputs.chkBotEnabled.toString(), 'local_db_service_account': inputs.local_db_service_account.toString(), 'open_txt_username': inputs.open_txt_username.toString(), 'serviceAcctOwner': inputs.serviceAcctOwner.toString(), 'dbextDatabase': '899b9f1e1bffac90fd762f876e4bcbfc', 'dbextChkNoDatabase': inputs.dbextChkNoDatabase.toString(), 'dbsecAppName': 'SystemOne', 'dbsecPlatform': 'Sybase', 'dbsecEnvironment': 'PROD', 'dbsecInstance': 'SYB_CADBURY2', 'dbsecDBName': 'gmpriv2dp', 'chcAccessType': inputs.chcAccessType.toString(), 'dbsecJobFunction': inputs.dbsecJobFunction.toString(), 'dbsecReasonForAccess': inputs.dbsecReasonForAccess.toString(), 'dbADGroup': inputs.dbADGroup.toString(), 'dbsecSameGroupAsDBOwner': inputs.dbsecSameGroupAsDBOwner.toString(), 'dbsecDBOwner': inputs.dbsecDBOwner.toString(), 'chkMultipleDatabases': inputs.chkMultipleDatabases.toString(), 'dbsecMultipleDatabaseInfo': inputs.dbsecMultipleDatabaseInfo.toString(), 'policy_data_mart': false } }; cart.addToCart(request); var cartDetails = cart.submitOrder(request); var newRequestId = cartDetails.request_id; var ritmGR = new GlideRecord('sc_req_item'); ritmGR.addQuery('request', newRequestId); ritmGR.orderByDesc('sys_created_on'); ritmGR.query(); if (ritmGR.next()) { ritmGR.request = inputs.existingRequestSysId; ritmGR.update(); } //var cartDetails = cart.orderNow(request); //var cartID = cartDetails.request_id; outputs.req_id = cartID; // Output the new RITM sys_id outputs.requested_for = requestedFor; } catch (e) { gs.error('#### Flow Action: Error creating RITM: ' + e.message); outputs.error = e.message; } })(inputs, outputs);