I am looking for a way to relink items in a form library using client-side JavaScript.

I've found this forum post on MSDN which has some PowerShell and C# code, but how can I do the same thing using JSOM?

1 Answer 1


Similar to the C# example on the link above, you can relink a document by setting its TemplateUrl field to the desired URI and saving the changes.

Here is a simple example of how you could do this for a single document, given a specific ID:

const listTitle = 'MyLibraryName';
const itemId = 12345;
const contentTypeUri = 'https://mysite.sharepoint.com/Library/Forms/template.xsn';

const context = SP.ClientContext.get_current();
const list = context.get_web().get_lists().getByTitle(listTitle);
const item = list.getItemById(itemId);

item.set_item('TemplateUrl', contentTypeUri);

    () => console.log('done'), 
    (_, e) => console.error(e.get_message())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.