Is there a script or way for batch adding Relationships to a Work from the search results page?

Is this what you are looking for?

It seems the bookmarklet will choose the default relationship type which is “medly of”, so you need to find a workaround to change it to “parts of”.

OK I found a workaround by temporarily modifying the bookmarklet to this by specifying the default value of parameter o:

javascript:(()=>{async function t(t){const e=await fetch("/ws/js/entity/"+t);return MB.entity(await e.json())}function e(t){const e=MB.sourceRelationshipEditor??MB.releaseRelationshipEditor;return new MB.relationshipEditor.UI.AddDialog({viewModel:e,source:e.source,target:t})}const i=prompt("MBIDs of entities which should be related to this entity:");i&&(async(i,o=281,n=!1)=>{for(let a of i){const i=e(await t(a));o&&(i.relationship().linkTypeID(o),n&&i.changeDirection()),i.accept()}})(Array.from(i.matchAll(/[0-9a-f-]{36}/gm),t=>t[0]))})();

281 is the link type ID of the “parts of” relationship.

3 Likes