Home > Appendices > Appendix E - Integration with ServiceNow > Run Scripts to Submit Requests
Export to PDFBelow are sample scripts you can leverage in ServiceNow to be able have users submit requests in ServiceNow and let Cloud Governance execute the service request. For more information about the sample script for each service type, refer to the sections below.
*Note: The site collection ID, team ID, or service ID are required when you run the following scripts to submit requests. To know how to get the IDs, refer to the instructions in How to get ID information?.
To submit a Create team service request, you need to execute the script in your own app within ServiceNow. The following is an example of the request that contains the required parameters.
For more information about the parameters in the script, refer to the schema provided by AvePoint Cloud Governance in AvePoint Cloud Governance API.
| try { var requestInfo = {}; requestInfo.groupId = "CreateTeamTestSNOW"; requestInfo.groupName = " CreateTeamTestSNOW "; requestInfo.policy = " xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx "; requestInfo.serviceId = " xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx "; requestInfo.summary = "Test SNOW Create Team"; requestInfo.members = []; var member = {}; member.loginName = "demo1@domain.com"; requestInfo.members.push(member); requestInfo.owners = []; var owner = {}; owner.loginName = "demo@domain.com"; requestInfo.owners.push(owner); requestInfo.primaryContact = {}; requestInfo.primaryContact.loginName = "demo1@domain.com" requestInfo.secondaryContact = {}; requestInfo.secondaryContact.loginName = "demo2@domain.com"; requestInfo.teamsSettings={}; requestInfo.teamsSettings.allowGuestsCreateUpdateChannels = false; requestInfo.teamsSettings.allowGuestsDeleteChannels = false; requestInfo.teamsSettings.allowMemberDeleteRestoreChannels = true; requestInfo.teamsSettings.allowMembersAddRemoveApps = true; requestInfo.teamsSettings.allowMembersCreatePrivateChannels = true; requestInfo.teamsSettings.allowMembersCreateUpdateChannels = true; requestInfo.teamsSettings.allowMembersCreateUpdateRemoveConnections = true; requestInfo.teamsSettings.allowMembersCreateUpdateRemoveTabs = true; requestInfo.teamsSettings.allowMembersDeleteMessages = true; requestInfo.teamsSettings.allowMembersEditMessages = true; requestInfo.teamsSettings.allowMentionsChannel = true; requestInfo.teamsSettings.allowMentionsTeam = true; requestInfo.teamsSettings.enableCustomMemes = true; requestInfo.teamsSettings.enableGiphy = true; requestInfo.teamsSettings.enableStickersAndMemes = true; requestInfo.teamsSettings.giphyRatingType = 0; //0:Strict 1:Moderate requestInfo.templateSettings = {};requestInfo.templateSettings.enableCreateTeamFromScratch = true; requestInfo.templateSettings.enableCloneApps = true; requestInfo.templateSettings.enableCloneChannels = true; requestInfo.templateSettings.enableCloneMembers = false; requestInfo.templateSettings.enableCloneTabs = true;; requestInfo.templateSettings.enableCloneTeamSetting = true; requestInfo.templateSettings.enableCreateTeamFromExistTeam = true; requestInfo.templateSettings.selectedTemplate = {}; requestInfo.templateSettings.selectedTemplate.id = " xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx "; requestInfo.templateSettings.selectedTemplate.name = "DemoTeam"; requestInfo.templateSettings.enableCreateTeamFromTeamTemplate = true; requestInfo.templateSettings.selectedMSTemplate = {}; requestInfo.templateSettings.selectedMSTemplate.id = "TeamTemplateId"; requestInfo.templateSettings.selectedMSTemplate.name = "TeamTemplateName"; requestInfo.metadatas =[]; var metadata = {}; metadata.name = "Demo Metadata"; metadata.value = "Demo Value"; metadata.type = 1; requestInfo.metadatas.push(metadata); gs.info("metadata: " + global.JSON.stringify(requestInfo.metadatas)); gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.CreateTeam', 'Post Create Team'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
|---|
Note the following:
| Parameter/Parameter Value in Script | Note |
|---|---|
| requestInfo.templateSettings.enableCreateTeamFromScratch – To create a team from scratch. Set it to true if you choose this team provisioning method.requestInfo.templateSettings.enableCreateTeamFromExistTeam – To create a team from an existing team. Set to true if you choose this team provisioning method.requestInfo.templateSettings.enableCreateTeamFromTeamTemplate – To create a team from a team template. Set to true if you choose this team provisioning method. | To determine how to create Microsoft Teams, you must enable one of these three properties and configure corresponding properties and values in your script, deciding a team is created from scratch, an existing team, or a team template. |
| x_avepo_cg_modern.CreateTeam | This is a sample value. You can enter a custom one in the format of “Application scope.REST API”, and:Replace the Application scope with the application scope that you copied in the REST Message Basic Information section.Replace the REST API with the REST API name that you configured in the REST Message Basic Information section. |
| Post Create Team | This is the HTTP method name that you configured in the Add HTTP Methods section. |
| data_center_url | This is the variable name of the endpoint that you configured in the REST Message Basic Information section. |
| x_avepo_cg_modern.data_center_url | This is the property name that you configured in the Create System Properties section. |
| gao_api_clientsecret | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_api_clientsecret | This is the property name that you configured in the Create System Properties section. |
| gao_user_name | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_user_name | This is the property name that you configured in the Create System Properties section. |
To submit a Change team settings service request, you need to execute the script in your own app within ServiceNow. The following is an example of the request that contains the required parameters.
For more information about the parameters in the script, refer to the schema provided by AvePoint Cloud Governance in AvePoint Cloud Governance API.
| try { var requestInfo = {}; requestInfo.serviceId = "xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupId = " xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx "; requestInfo.groupEmail = "Demo@domain.com" requestInfo.summary = "Change Team Test Demo"; requestInfo.groupMetadatas = []; var groupMetadata = {}; groupMetadata.action = 2; groupMetadata.name = "Demo_Metadata"; groupMetadata.value = "demo value"; requestInfo.groupMetadatas.push(groupMetadata); requestInfo.groupName = "name changed"; requestInfo. originalGroupName = "name"; requestInfo.groupMembers = []; var member = {}; member.action = 2; member.displayName = "Demo1"; member.loginName = "Demo1@domain.com"; requestInfo.groupMembers.push(member); requestInfo.groupOwners = []; var owner = {}; owner.action = 1; owner.displayName = "Demo"; owner.loginName = "Demo@domain.com"; requestInfo.groupOwners.push(owner); requestInfo.metadatas =[]; var metadata = {}; metadata.name = "Demo_Metadata"; metadata.value = "Demo"; requestInfo.metadatas.push(metadata); gs.info("metadatas: " + global.JSON.stringify(requestInfo.metadatas)); gs.info(global.JSON.stringify(requestInfo));sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.ChangeTeam', 'Post Change Team'); sm.setStringParameter('data_center_url',gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret",gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret'));sm.setStringParameter("gao_user_name",gs.getProperty('x_avepo_cg_modern.gao_user_name'));sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute();var requestId = response.getBody().replace(/"/g, '');var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$");if (requestId.match(reg) != null) {gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
|---|
Note the following:
| Parameter/Parameter Value in Script | Note |
|---|---|
| x_avepo_cg_modern.ChangeTeam | This is a sample value. You can enter a custom one in the format of “Application scope.REST API”, and then:Replace the Application scope with the application scope that you copied in the REST Message Basic Information section.Replace the REST API with the REST API name that you configured in the REST Message Basic Information section. |
| Post Change Team | This is the HTTP method name that you configured in the Add HTTP Methods section. |
| data_center_url | This is the variable name of the endpoint that you configured in the REST Message Basic Information section. |
| x_avepo_cg_modern.data_center_url | This is the property name that you configured in the Create System Properties section. |
| gao_api_clientsecret | Replace with the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_api_clientsecret | This is the property name that you configured in the Create System Properties section. |
| gao_user_name | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_user_name | This is the property name that you configured in the Create System Properties section. |
To submit an Invite new guest user service request, you need to execute the script in your own app within ServiceNow. The following is an example of the request that contains the required parameters.
For more information about the parameters in the script, refer to the schema provided by AvePoint Cloud Governance in AvePoint Cloud Governance API.
| try { var requestInfo = {}; requestInfo.serviceId = " xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx "; requestInfo.summary = "summary"; requestInfo.notesToApprovers = "notesToApprovers"; requestInfo.primaryContact = {}; requestInfo.primaryContact.loginName = "Demo1@domain.com" requestInfo.secondaryContact = {}; requestInfo.secondaryContact.loginName = " Demo2@domain.com "; requestInfo.oneTimeSettings={} requestInfo.oneTimeSettings.option=1; requestInfo.oneTimeSettings.durationType=0; requestInfo.oneTimeSettings.duration=3; requestInfo.oneTimeSettings.startTime="2021-11-25T00:00:00.000Z"; requestInfo.welcomeEmailMessage = "welcome Email Message" requestInfo.type=68; requestInfo.userProperties={}; requestInfo.userProperties.userName="test@outlook.com"; requestInfo.userProperties.usageLocation="US"; requestInfo.userProperties.jobTitle=""; requestInfo.userProperties.jobDepartment=""; requestInfo.userProperties.companyName=""; requestInfo.userProperties.manager={}; requestInfo.userProperties.manager.loginName=" Demo@domain.com "; requestInfo.metadatas =[]; var metadata = {}; metadata.name = "Api_Sample_SingleLine"; metadata.value = "testValue"; metadata.type = 1; requestInfo.metadatas.push(metadata); gs.info("metadata: " + global.JSON.stringify(metadata)); requestInfo.inviteGroups =[]; //var inviteGroup = {}; //inviteGroup.loginName = "test@domain.com"; //requestInfo.inviteGroups.push(inviteGroup); requestInfo.questionnaireId = ""; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.SubmitRequest', 'Post Invite Guest User'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
|---|
Note the following:
| Parameter/Parameter Value in Script | Note |
|---|---|
| x_avepo_cg_modern.SubmitRequest | This is a sample value. You can enter a custom one in the format of “Application scope.REST API”, and then:Replace the Application scope with the application scope that you copied in the REST Message Basic Information section.Replace the REST API with the REST API name that you configured in the REST Message Basic Information section. |
| Post Invite Guest User | This is the HTTP method name that you configured in the Add HTTP Methods section. |
| data_center_url | This is the variable name of the endpoint that you configured in the REST Message Basic Information section. |
| x_avepo_cg_modern.data_center_url | This is the property name that you configured in the Create System Properties section. |
| gao_api_clientsecret | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_api_clientsecret | This is the property name that you configured in the Create System Properties section. |
| gao_user_name | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_user_name | This is the property name that you configured in the Create System Properties section. |
To submit a Team lifecycle management request, you need to execute the script in your own app within ServiceNow. The following is an example of a request that contains the required parameters.
For more information about the parameters in the script, refer to the schema provided by AvePoint Cloud Governance in AvePoint Cloud Governance API.
| Lifecycle Management Action | Sample Script |
|---|---|
| Restore team | try{ var requestInfo = {}; requestInfo.summary = "TestSNOW_RestoreGroup"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupEmail = "Demo@domain.com"; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.GroupLifecycle', 'Post Restore Group'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Delete team | try{ var requestInfo = {}; requestInfo.summary = "TestSNOW_DeleteGroup"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupEmail = "Demo@domain.com"; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.GroupLifecycle', 'Post Delete Group'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Archive team | try{ var requestInfo = {}; requestInfo.summary = "TestSNOW_ArchiveGroup"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupEmail = "Demo@domain.com"; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.GroupLifecycle', 'Post Archive Group'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Extend team lease | try{ var requestInfo = {}; requestInfo.summary = "TestSNOW_ExtendGroupLease"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupEmail = "Demo@domain.com"; requestInfo.extendDuration = 50; requestInfo.extendDurationType = 0;//0: Days 1:Weeks 2:Months 3:Years gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.GroupLifecycle', 'Post Extend Group'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Change group team site storage | try{ var requestInfo = {}; requestInfo.summary = "TestSNOW_ChangeGroupQuota"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupEmail = "Demo@domain.com"; requestInfo.groupQuotaSize = 2; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.GroupLifecycle', 'Post Change Group Quota'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Change team policy | try{ var requestInfo = {}; requestInfo.summary = "TestSNOW_ChangeGroupPolicy"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.groupEmail = "Demo@domain.com"; requestInfo.policy = {}; requestInfo.policy.id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.policy.name = "Demo_GroupInactivityPolicy"; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.GroupLifecycle', 'Post Change Group Policy'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
Note the following:
| Parameter/Parameter Value in Script | Note |
|---|---|
| x_avepo_cg_modern.GroupLifecycle | This is a sample value. You can enter a custom one in the format of Application scope.REST API, and:Replace the Application scope with the application scope that you copied in the REST Message Basic Information section.Replace the REST API with the REST API name that you configured in the REST Message Basic Information section. |
| The HTTP method name should vary with different team lifecycle management action:Post Restore GroupPost Extend GroupPost Delete GroupPost Change Group QuotaPost Change Group PolicyPost Archive Group | These are the HTTP method names that you configured in the Add HTTP Methods section. |
| data_center_url | This is the variable name of the endpoint that you configured in the REST Message Basic Information section. |
| x_avepo_cg_modern.data_center_url | This is the property name that you configured in the Create System Properties section. |
| gao_api_clientsecret | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_api_clientsecret | This is the property name that you configured in the Create System Properties section. |
| gao_user_name | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_user_name | This is the property name that you configured in the Create System Properties section. |
To submit a Create site collection service request, you need to execute the script in your own app within ServiceNow. The following is an example of a request that contains the required parameters.
For more information about the parameters in the script, refer to the schema provided by AvePoint Cloud Governance in AvePoint Cloud Governance API.
| try{var requestInfo = {};requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";requestInfo.metadatas = [];var metadata = {};metadata.name = "Publish to Directory";metadata.value = true;requestInfo.metadatas.push(metadata);requestInfo.summary = "TestSNOW_CreateSC";requestInfo.siteTitle = "TestSNOW_CreateSC";requestInfo.siteUrl = {};requestInfo.siteUrl.managedPath = "/sites/";requestInfo.siteUrl.name = "TestSNOW_CreateSC";requestInfo.siteUrl.root = "https://xxxx.sharepoint.com";requestInfo.timeZone = 39;requestInfo.language = 2052;requestInfo.policyId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";requestInfo.template = "STS#3#Team site (no Microsoft 365 group)#Collaboration";requestInfo.deploymentManagerPlanName = "demo panel plan";requestInfo.primaryAdmin = {};requestInfo.primaryAdmin.loginName = "Demo@domain.com";requestInfo.additionalAdmins = [];var additionalAdmin = {};additionalAdmin.loginName = "Demo1@domain.com";requestInfo.additionalAdmins.push(additionalAdmin);requestInfo.primaryContact = {};requestInfo.primaryContact.loginName = "Demo2@domain.com";requestInfo.secondaryContact = {};requestInfo.secondaryContact.loginName = "Demo3@domain.com";requestInfo.userPermissions = [];var userPermission = {};userPermission.permissionLevels = [];var permissionLevel = {};permissionLevel.name = "View Only";userPermission.permissionLevels.push(permissionLevel);userPermission.user = {};userPermission.user.loginName = "test@domain.space";requestInfo.userPermissions.push(userPermission);requestInfo.groupPermissions = [];var groupPermissionOwner = {};groupPermissionOwner.name = "$SiteName Owners";groupPermissionOwner.users = [];var user = {};user.loginName = "demo@domian.space";groupPermissionOwner.users.push(user);groupPermissionOwner.permissionLevels = [];var permissionLevel = {};permissionLevel.name = "Full Control";groupPermissionOwner.permissionLevels.push(permissionLevel);requestInfo.groupPermissions.push(groupPermissionOwner);var groupPermissionMember = {};groupPermissionMember.name = "$SiteName Members";groupPermissionMember.users = [];groupPermissionMember.permissionLevels = [];var permissionLevel = {};permissionLevel.name = "Edit";groupPermissionMember.permissionLevels.push(permissionLevel);requestInfo.groupPermissions.push(groupPermissionMember);var groupPermissionVisitor = {};groupPermissionVisitor.name = "$SiteName Visitors";groupPermissionVisitor.users = [];groupPermissionVisitor.permissionLevels = [];var permissionLevel = {};permissionLevel.name = "Read";groupPermissionVisitor.permissionLevels.push(permissionLevel);requestInfo.groupPermissions.push(groupPermissionVisitor);requestInfo.leasePeriodSettings = {};requestInfo.leasePeriodSettings.leaseDurationType = 0;//0: Days 1:Weeks 2:Months 3:YearsrequestInfo.leasePeriodSettings.leaseInterval = 100;gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.CreateSiteCollection', 'Post Create Site Collection'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
|---|
Note the following:
| Parameter/Parameter Value in Script | Note |
|---|---|
| x_avepo_cg_modern.CreateSiteCollection | This is a sample value. You can enter a custom one in the format of Application scope.REST API, and:Replace the Application scope with the application scope that you copied in the REST Message Basic Information section.Replace the REST API with the REST API name that you configured in the REST Message Basic Information section. |
| Post Create Site Collection | This is the HTTP method name that you configured in the Add HTTP Methods section. |
| data_center_url | This is the variable name of the endpoint that you configured in the REST Message Basic Information section. |
| x_avepo_cg_modern.data_center_url | This is the property name that you configured in the Create System Properties section. |
| gao_api_clientsecret | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_api_clientsecret | This is the property name that you configured in the Create System Properties section. |
| gao_user_name | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_user_name | This is the property name that you configured in the Create System Properties section. |
To submit a Change site collection settings service request, you need to execute the script in your own app within ServiceNow. The following is an example of the request that contains the required parameters.
For more information about the parameters in the script, refer to the schema provided by AvePoint Cloud Governance in AvePoint Cloud Governance API.
| try{ var requestInfo = {}; requestInfo.summary = "TestSnow_Change SC Settings"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteUrl = "https://xxxx.sharepoint.com/sites/demoPanel"; requestInfo.siteTitleSetting = {}; requestInfo.siteTitleSetting.changeValue = "demoPanel"; requestInfo.siteTitleSetting.originalValue = "demoPanel"; requestInfo.siteDescriptionSetting = {}; requestInfo.changedMetadatas = []; var metadata = {} metadata.action = 1;//0: NoChange 1:Add 2:Edit -1:\Delete metadata.name = "Api_Sample_SingleLine"; metadata.value = "test snow"; requestInfo.changedMetadatas.push(metadata); requestInfo.deploymentPlanName = "demo panel plan"; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.ChangeSCSettings', 'Post Change SiteCollection Settings'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
|---|
Note the following:
| Parameter/Parameter Value in Script | Note |
|---|---|
| x_avepo_cg_modern. ChangeSCSettings | This is a sample value. You can enter a custom one in the format of Application scope.REST API, and:Replace the Application scope with the application scope that you copied in the REST Message Basic Information section.Replace the REST API with the REST API name that you configured in the REST Message Basic Information section. |
| Post Change SiteCollection Settings | This is the HTTP method name that you configured in the Add HTTP Methods section. |
| data_center_url | This is the variable name of the endpoint that you configured in the REST Message Basic Information section. |
| x_avepo_cg_modern.data_center_url | This is the property name that you configured in the Create System Properties section. |
| gao_api_clientsecret | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_api_clientsecret | This is the property name that you configured in the Create System Properties section. |
| gao_user_name | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_user_name | This is the property name that you configured in the Create System Properties section. |
To submit a Create team service request, you need to execute the script in your own app within ServiceNow. The following is an example of a request that contains the required parameters.
For more information about the parameters in the script, refer to the schema provided by AvePoint Cloud Governance in AvePoint Cloud Governance API.
| Lifecycle Management Action | Sample Script |
|---|---|
| Unlock site collection | try{ var requestInfo = {}; requestInfo.summary = "TestSnow_Unlock SC"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteUrl = "https://xxxx.sharepoint.com/sites/demoPanel"; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.SiteCollectionLifecycle', 'Post Unlock SiteCollection'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Lock site collection | try{ var requestInfo = {}; requestInfo.summary = "TestSnow_Lock SC"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteUrl = "https://xxxx.sharepoint.com/sites/demoPanel"; requestInfo.lockType = 0; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.SiteCollectionLifecycle', 'Post Lock SiteCollection'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Lock site collection | *Note: When configuring the property requestInfo.lockType, the lock status varies with different property value that you specified:● 0 – Lock the site in “no access” status.● 1 – Lock the site in “read-only” status. |
| Archive site collection | try{ var requestInfo = {}; requestInfo.summary = "TestSnow_Archive SC"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteUrl = "https://xxxx.sharepoint.com/sites/demoPanel"; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.SiteCollectionLifecycle', 'Post Archive SiteCollection'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Delete site collection | try{ var requestInfo = {}; requestInfo.summary = "TestSnow_Delete SC"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteUrl = "https://xxxx.sharepoint.com/sites/demoPanel"; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.SiteCollectionLifecycle', 'Post Delete SiteCollection'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Extend site collection lease | try{ var requestInfo = {}; requestInfo.summary = "TestSnow_Extend SC"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteUrl = "https://xxxx.sharepoint.com/sites/demoPanel"; requestInfo.extendDuration = 50; requestInfo.extendDurationType = 0;//0: Days 1:Weeks 2:Months 3:Years gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.SiteCollectionLifecycle', 'Post Extend SiteCollection Lease'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Change site collection storage | try{ var requestInfo = {}; requestInfo.summary = "TestSnow_Change SC Quota"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteUrl = "https://xxxx.sharepoint.com/sites/demoPanel"; requestInfo.quotaSize = 2; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.SiteCollectionLifecycle', 'Post Change SiteCollection Quota'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
| Change site collection policy | try{ var requestInfo = {}; requestInfo.summary = "TestSnow_Change SC Policy"; requestInfo.serviceId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; requestInfo.siteUrl = "https://xxxx.sharepoint.com/sites/demoPanel"; requestInfo.policy = {}; requestInfo.policy.id = "d95f5f20-9955-4199-966f-5d28e77748ec"; requestInfo.policy.name = "SC Inactivity Policy"; gs.info(global.JSON.stringify(requestInfo)); sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.SiteCollectionLifecycle', 'Post Change SiteCollection Policy'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setRequestBody(global.JSON.stringify(requestInfo)); response = sm.execute(); var requestId = response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (requestId.match(reg) != null) { gs.info('Successfully submitted the request via Cloud Governance API. Request Id: ' + requestId); } else { gs.error('An error occurred when submitting the request via Cloud Governance API. Details: ' + requestId); }} catch (ex) { gs.error(ex);} |
Note the following:
| Parameter/Parameter Value in Script | Note |
|---|---|
| x_avepo_cg_modern.SiteCollectionLifecycle | This is a sample value. You can enter a custom one in the format of Application scope.REST API, and:Replace the Application scope with the application scope that you copied in the REST Message Basic Information section.Replace the REST API with the REST API name that you configured in the REST Message Basic Information section. |
| The HTTP method name should vary with different site collection lifecycle management action:Post Lock SiteCollectionPost Unlock SiteCollectionPost Extend SiteCollection LeasePost Delete SiteCollectionPost Change SiteCollection QuotaPost Change SiteCollection PolicyPost Archive SiteCollection | These are the HTTP method names that you configured in the Add HTTP Methods section. |
| data_center_url | This is the variable name of the endpoint that you configured in the REST Message Basic Information section. |
| x_avepo_cg_modern.data_center_url | This is the property name that you configured in the Create System Properties section. |
| gao_api_clientsecret | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_api_clientsecret | This is the property name that you configured in the Create System Properties section. |
| gao_user_name | This is the HTTP header name that you configured in the Add HTTP Headers section. |
| x_avepo_cg_modern.gao_user_name | This is the property name that you configured in the Create System Properties section. |
For how to get the site collection ID, team ID, or service ID, refer to the instructions in the following sections:
The site collection ID is required when you run a script to submit a Site collection lifecycle management service request or Change site collection settings service request.
To get the site collection ID for a Site collection lifecycle management service request, complete the following steps:
${data_center_url}/services/sitelifecycle/${serviceId}/url/validation
For how to create a REST message, refer to instructions in Create REST Message.
| try{ var serviceId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx"; var validationInfo= {}; validationInfo.uri = "https://xxxxx.sharepoint.com/sites/demoSC"; sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.Validate Site', 'Post Validate SC lifecycle'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setStringParameter("serviceId", serviceId); sm.setRequestBody(global.JSON.stringify(validationInfo)); response = sm.execute(); var result= response.getBody(); gs.info("Validate url for sc lifecycle service, details is: " + result} catch (ex) { gs.error(ex);} |
|---|
To get the site collection ID for a Change site collection settings service request, complete the following steps:
${data_center_url}/services/changesitesetting/${serviceId}/url/validation
For how to create a REST message, refer to the instructions in Create REST Message.
| try{ var serviceId = "xxxxxx-xxxx-xxxx-xxxxxx"; var validationInfo= {}; validationInfo.uri = "https://xxxx.sharepoint.com/sites/demoSC"; sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.Validate Site', 'Post Validate Change SC'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setStringParameter("serviceId", serviceId); sm.setRequestBody(global.JSON.stringify(validationInfo)); response = sm.execute(); var result= response.getBody(); gs.info("Validate url for change sc service, details is: " + result} catch (ex) { gs.error(ex);} |
|---|
The team ID is required when you run a script to submit a Team lifecycle management service request or Change team settings service request.
To get the team ID for a Team lifecycle management service request or Change team settings service request, complete the following steps:
Create a REST message in ServiceNow using the following endpoint URL:
${data_center_url}/users/resolve?keyword=${groupemail}&userType=4&sharingOptions=0&userSource=2
For how to create a REST message, refer to the instructions in Create REST Message.
| try{ var groupEmail = "demo@domain.com"; sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.Resolve Group', 'Get ACG Group'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setStringParameter("groupemail", groupEmail); sm.setRequestBody(); response = sm.execute(); var result= response.getBody(); gs.info("Get group by group email, details is: " + result} catch (ex) { gs.error(ex);} |
|---|
The service ID is required when you run a script to submit a service request.
To get the service ID for a service, complete the following steps:
${data_center_url}/services/id?name=${name}
For how to create a REST message, refer to the instructions in Create REST Message.
| try{ var serviceName= "demo change team"; sm = new sn_ws.RESTMessageV2('x_avepo_cg_modern.Get Service Id', 'Get ServiceId By Name'); sm.setStringParameter('data_center_url', gs.getProperty('x_avepo_cg_modern.data_center_url')); sm.setStringParameter("gao_api_clientsecret", gs.getProperty('x_avepo_cg_modern.gao_api_clientsecret')); sm.setStringParameter("gao_user_name", gs.getProperty('x_avepo_cg_modern.gao_user_name')); sm.setStringParameter("name", serviceName.replaceAll(" ", "%20")); sm.setRequestBody(); response = sm.execute(); var result= response.getBody(); var serviceId= response.getBody().replace(/"/g, ''); var reg = new RegExp("^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); if (serviceId.match(reg) != null && serviceId != "00000000-0000-0000-0000-000000000000") { gs.info('Successfully get service id. Service Id: ' + serviceId); } else { gs.error('Failed to get service id by service name, please check whether your service name is right. Details: ' + serviceId); }} catch (ex) { gs.error(ex);} |
|---|