Rename a document in sharepoint to a custom name

lock
push_pin
done
Besvart
3

Hello everyone,

if this is the wrong forum for my question, take my apologies and please guide me to the correct forum...

I do want to rename a file (saved to sharepoint) based to the header name with CRMscript. But at least for our tenant, this does not work.

The script basically does this:

    String myNewHeader = myWantedHeader + docheader;
    String myDocumentName = myWantedHeader + docheader + ".docx";

    thing.SetHeader(myNewHeader);
    thing.SetName(agent.RenameDocument(myDocID, myDocumentName));
    agent.SaveDocumentEntity(thing);

The Header is set right, but the document does not seem to be renamed in sharepoint.

Also i do not get any error message - it just does not work.

Am i doing something wrong here?

Thanks and kind regards

Joerg Hermanns

 

10. jul. 2024 | 07:38 p.m.

Alle Svar (3)

Anybody ... ?

Am i the only one having this problem ??

6. aug. 2024 | 11:51 a.m.

Hello Jörg, 

I'm a little unsure about your code-snippet. Specifically this line:
```
  thing.SetName(agent.RenameDocument(myDocID, myDocumentName));
```
Is there a reason why you use the RenameDocument on the Agent in this way?

May I suggest you just set the name directly instead?
```
#setLanguageLevel 4;
NSDocumentAgent dAgent;
NSDocumentEntity dEntity = dAgent.GetDocumentEntity(59);
dEntity.SetName("NewName.docx");
dAgent.SaveDocumentEntity(dEntity);
```

That being said I can reproduce the issue with renaming documents when you use sharepoint. I'm looking into it and will get back to you in this thread when i have more information, hopefully the first part of next week. 

Have a SUPER day!

//Eivind

9. aug. 2024 | 11:47 a.m.

Hello Jörg, 

After digging into this there seems to be an issue with renaming files that are stored in sharepoint. 
We have created a bugreport on it, hopefully it will get fixed in the future..

Sorry!

//Eivind

13. aug. 2024 | 11:16 a.m.

Legg til svar