1

I am trying to use window.open(); to open a new window and to add parameters to the end of the URL. However when I enter curly braces {} it converts it to the hex code (%7b and %7d).

Does anyone know how to actually make these print out in plain text?

{!REQUIRESCRIPT("/soap/ajax/21.0/connection.js")}

sforce.connection.sessionId = '{!$Api.Session_ID}';

function errorMsg() {
    if (**field 1** == "") {
        return "Error please check all fields are completed";
    } else return "";
}

var error = errorMsg();
if (error != ''){
    alert(error);
    console.log('####' + error);
    } else if (error == ''){
    window.open("https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId={!API.Session_ID}&serverUrl={!API.Partner_Server_URL_80}&id={!Opportunity.Id}&ESContactid={QVar0}","","width=700,height=450");
}

I have tried converting the curly braces to the, usually accepted, oct codes (\173) but I still get the same %7b output :/

I have also tried splitting the URL and having the {QVar0} in a separate sting and just adding them together:

window.open("https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId={!API.Session_ID}&serverUrl={!API.Partner_Server_URL_80}&id={!Opportunity.Id}&ESContactid=" + "{QVar0}");

But again same output :/

p.s my actual code and URL are a lot longer... I just got rid of the crap so it was easier to read :)

Thanks for all comments in advance :)

  • I don't think those are acceptable in an URL without encoding. Might be worth to add the conga comment you added on stackoverflow. – Samuel De Rycke Feb 26 '14 at 11:02
0

Thanks all for your comments I have fixed this :)

I was silly and made things too complicated.... decodeURIComponent()

{!REQUIRESCRIPT("/soap/ajax/21.0/connection.js")}

sforce.connection.sessionId = '{!$Api.Session_ID}';

function errorMsg() {
    if (**field 1** == "") {
        return "Error please check all fields are completed";
    } else return "";
}

var error = errorMsg();

var URL = decodeURIComponent("https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId={!API.Session_ID}&serverUrl={!API.Partner_Server_URL_80}&id={!Opportunity.Id}&ESContactid={QVar0}");

if (error != ''){
    alert(error);
    console.log('####' + error);
    } else if (error == ''){
    window.open(URL,"","width=700,height=450");
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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