How to Create Folder/ Sub Folder from Servicenow to Share Point

SaiRaviKiran Ak
Giga Guru

Client has a share point and wanted to create folder when case is updated with RITM number. Is there any possibility to create folder from servicenow system to share point on Updation of case in servicenow.

 

Any help would be appreciated.

 

Thank you.

3 REPLIES 3

Riya Verma
Kilo Sage

Hi @SaiRaviKiran Ak ,

 

Hope you are doing great. 

 

Here's a high-level solution for your scenario:

  1. Establish a connection between ServiceNow and SharePoint using the SharePoint REST API or SharePoint Connector in ServiceNow. This connection allows ServiceNow to interact with SharePoint.

  2. Define a business rule or script in ServiceNow that triggers when a case is updated. This rule should extract the RITM number associated with the case.

  3. Utilize the SharePoint integration within ServiceNow to invoke the SharePoint REST API and create a folder in the desired SharePoint location. You can specify the folder name as the RITM number obtained from the case update.

Below is snippet which you can reference:

// Assuming 'ritmNumber' contains the extracted RITM number
var folderName = ritmNumber;

// Use the SharePoint REST API endpoint to create the folder
var sharepointURL = "https://your-sharepoint-site.com/api/createfolder";
var requestBody = {
  folderName: folderName,
  location: "/path/to/sharepoint/folder"
};

// Make an HTTP request to create the folder in SharePoint
var response = gs.restPost(sharepointURL, requestBody);

// Check the response status to ensure the folder creation was successful
if (response && response.statusCode == 201) {
  gs.info("Folder created in SharePoint: " + folderName);
} else {
  gs.error("Failed to create folder in SharePoint. Please check the integration configuration.");
}

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Hi Riya, @Riya Verma 

Is there a way to also populate metadata while creating a SharePoint folder from ServiceNow via integration?

Shyam13
Tera Contributor

test