Include configurable text in script from ScriptLibrary

I have a script that makes an http request with a hard coded url - how do I make this configurable so that the users can edit it in the future without having to edit the script?

Parents
  • Without more detail I am not sure how 'editable' it needs to be and by what mechanism.

    If you simply want an admin to be able to change the URL without changing your script you can put the url in a seperate SL called CustEndPoint that would contain 1 line:

    function webservice1() { return "">http://whatever" };

    then in your script the url would be

    var url = lib.CustEndPoint.webservice1();

    and your script would never need to change.  The admin could change the url in CustEndPoint when needed.

    If you mean how to let an end user do this from the UI, then you need a form, with a url field and then you pass that url into your JS as a parameter to a function.

Reply
  • Without more detail I am not sure how 'editable' it needs to be and by what mechanism.

    If you simply want an admin to be able to change the URL without changing your script you can put the url in a seperate SL called CustEndPoint that would contain 1 line:

    function webservice1() { return "">http://whatever" };

    then in your script the url would be

    var url = lib.CustEndPoint.webservice1();

    and your script would never need to change.  The admin could change the url in CustEndPoint when needed.

    If you mean how to let an end user do this from the UI, then you need a form, with a url field and then you pass that url into your JS as a parameter to a function.

Children
No Data