Changing the name of an object in Document Management with code
The name of a file or folder in Document Management can be changed using the following codes.
Required Libraries
using System;
using System.Collections.Generic;
using Bimser.CSP.FormControls.Common;
using Bimser.CSP.FormControls.Controls;
using Bimser.CSP.FormControls.Events;
using Bimser.Synergy.Entities.Shared.Business.Objects;
using Bimser.Synergy.ServiceAPI;
using Bimser.Synergy.ServiceAPI.Models.Authentication;
using Bimser.Synergy.ServiceAPI.Models.Form;
using Newtonsoft.Json;
using Bimser.Synergy.Entities.DocumentManagement.Business.DTOs.Requests;
using Bimser.Synergy.Entities.DocumentManagement.Business.DTOs.Responses;
using Bimser.Framework.Web.Models;
using System.Linq;
Required Codes
public GetDMObjectResponse GetDMObjectInfo(string path)
{
WrapResponse```<```GetDMObjectsResponse```>``` dmObject = ServiceApi.DocumentManagement.GetDMObjectsFromPath(
new GetDMObjectsFromPathRequest(path)). Result;
GetDMObjectResponse dMObjectResponse = dmObject.Result.Items.First();
return dMObjectResponse;
}
void Button1_OnClick(object sender, MouseEventArgs e)
{
GetDMObjectResponse dmObject = GetDMObjectInfo("Path Information of the File to Rename");//with the file name and extension (if any)
ServiceApi.DocumentManagement.RenameObject(
new RenameObjectRequest(dmObject.SecretKey,dmObject.DecryptedObjectSecret)
{
NameML = new Dictionary```<```string, string```>```{
{"en-US","yeniIsim.png"},//As an example (if any), the file extension should also be given in this way.
{"en-US","newName.png"}
}
}
);
}