JSAPI createLink no longer working


(M L Sanders) #1

Matrix Version: 5.3.3.0

A colleague developed some JS-API code to link a newly created image as the thumbnail of another asset (the targetted parent asset id is passed in via the URL).

The code - which was developed while we had v.4.?.? of Matrix installed - looks like this:

js_api.createLink({
“parent_id”: getURLParameter(“userid”),
“child_id”: %created_assetid%,
“link_type”: 8,
“link_value”: “thumbnail”,
“sort_order”: -1,
“is_dependant”: 0,
“is_exclusive”: 0
});

The parent_id bit is worked out in a seperate function:

function getURLParameter(name) {
return decodeURIComponent((new RegExp(’[?|&]’ + name + ‘=’ + ‘([^&;]+?)(&|#|;|$)’).exec(location.search)||[,""])[1].replace(/+/g, ‘%20’))||null;
}

This used to work, but the ‘created asset’ is now NOT linked to the appropriate asset (whose id is passed in via the URL).

Can anyone see anything in the code that won’t work due to a change in version, perhaps?

Many thanks
mark


(Bart Banda) #2

Not sure, but what happens if you run that createLink JS API function and just hardcode the parent_id and child_id values in for testing? That should narrow down the issue.

Also, do you get any errors after running the createLink function? And what’s the respone look like after it fires?