1

I have a managed package object which has a button called Public Link which executes Javascript and displays a public URL in an iframe.

Is it possible to see the javascript function code and save the value in the iframe to record?

edit: This is the code in the script section of the button

 window.invokeOnClickJS_00bR0000000EbrP = function(element) {
     function getRecordIds(keyPrefix) { return 
     Scontrol.prototype.getSelectedRecordIdsFromForm(element.form, keyPrefix); }

     element.invokeAction = function() { 
     var scriptLibrary = [];
     Util.loadScripts(scriptLibrary, 0, function() {
     try { 
     Sfdc.logServer('JAVASCRIPT_BUTTON', {id: '00bR0000000EbrP', name: 'lmscons__Public_Link'}, Sfdc.Logging.LogLevel.INFO);
     Util.stripCustomFunctionFromObjectPrototype(Array);eval('openPublicLink();') } catch (e) { alert('A problem with the OnClick JavaScript for this button or link was encountered:\n\n' + (e.message ? e.message : e)) }
     finally { Util.restoreCustomFunctionsToObjectPrototype(Array);}
});
  };
element.invokeAction();

}

openPublicLink=function(){A4J.AJAX.Submit('j_id0:j_id11',null,{'similarityGroupingId':'j_id0:j_id11:j_id28','oncomplete':function(request,event,data){completeGetPublicLink()},'parameters':{'j_id0:j_id11:j_id28':'j_id0:j_id11:j_id28'} ,'status':'j_id0:loadStatus'} )};


function completeGetPublicLink() {
 jQuery('#publikUrl').show();
 jQuery('#uploadForm').hide();
 jQuery('#TitleUp').text('Public Link');

 var PublicLink = jQuery('[id$="CFS_pLink"]').val();
 //jQuery('#publikUrl').text(jQuery('[id$="pLink"]').val());


 jQuery('#publikUrl').empty();

 jQuery('#publikUrl').append('<textarea cols="105" rows="4" readonly="true">'+PublicLink+'</textarea>');

 Lightbox();
 //alert(jQuery('[id$="pLink"]').val());
}

1 Answer 1

0

If it is a JavaScript button in the managed package then the API it uses has to be global so other code can invoke that API. If you use your browser's Developer Tools Inspect right click menu, you can see the HTML/JavaScript in the page for that button and work back to the JavaScript function called something like window.invokeOnClickJS_00bA0000000icfU. In that you will find a call to sforce.apex.execute (not that this is in an escaped string form in the page) and that lets you know what global API is being used. You can then create your own OnClick JavaScript custom button (Google about that) that uses the same API and adds the behaviour you want.

Note however that while the global API can never be removed by the managed package vendor they are not really under any obligation to document the API or keep the API working. So best to contact the vendor if this is an important change for you.

PS

Based on the detail posted this looks like a custom button probably in a custom page. I would not recommend trying to leverage that as no global API is involved (and if its in a custom page you can't modify it anyway).

Instead contact the managed package vendor.

3
  • I found the script but there is no call to sforce.apex.execute in it.
    – Ishan
    Jan 17, 2018 at 10:50
  • @Ishan Not too sure why the difference, but look for the JavaScript function openPublicLink and see what it does.
    – Keith C
    Jan 17, 2018 at 11:00
  • I updated the code in the question
    – Ishan
    Jan 17, 2018 at 11:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .