4

URL Image I am connecting to the URL by using custom button when Update__c = true condition reamin all conditions these button connect to different URL. but when i used below code it showing URL Breaks, but the URl is working.I placed this code in Buttons Section. but IN URL it showing like that

https://na15.salesforce.com/servlet/if(%27true%27%20==%20%27true%27)%7B%20%20%20%20window.location.href%20=%20%27/_ui/core/email/author/EmailAuthor?id=a00i000000KtP5X%27%20;}

 if('{!Quote__c.Updated__c}' == 'true')
 {
   window.location.href = '/_ui/core/email/author/ EmailAuthor?id={!Quote__c.Id}' ;
}

3 Answers 3

3

If you want to execute JavaScript when the button is clicked (for your conditional logic), you need to use the "Execute JavaScript" and "OnClick JavaScript" options.

9
  • when i click the email button it is not connecting to link which i was provide.Showing in Pop-up UNexpected Token Illegal.
    – Sathya
    Apr 22, 2014 at 8:31
  • @Sathya Based on your screen shot you appear to have put a line break in the middle of the JavaScript string. Ensure that this "window.location.href = '/_ui/core/email/author/EmailAuthor?id={!Quote__c.Id}';" is all on one line.
    – Keith C
    Apr 22, 2014 at 8:39
  • Right Now i am checking the Quote__c.Update__c = true, but i want to check the Quote_Line__c.Update__c = true at that time only email button action have to perform.
    – Sathya
    Apr 23, 2014 at 10:30
  • @Sathya Then your JavaScript will have to reference the input field itself to use the current value (rather than the value when the page was rendered).
    – Keith C
    Apr 23, 2014 at 10:33
  • Can you give suggestions where i have to update my javascript code.
    – Sathya
    Apr 23, 2014 at 10:36
3
<apex:page>
<div id="output"></div>
<apex:includeScript value="/soap/ajax/28.0/connection.js"/>
<apex:includeScript value="/soap/ajax/28.0/apex.js"/>
<script>
    sforce.connection.sessionId = "{!$Api.Session_ID}";

    function setupPage() {

        var output = document.getElementById("output");
            alert(output);
        var startTime = new Date().getTime()

         try {
            var queryResult = sforce.connection.query("Select Id, Name,Industry From Account ");
            layoutResults(queryResult, output, startTime);
        } catch(error) {
            queryFailed(error, output);
        }
    }

    function queryFailed(error, out) {
        out.innerHTML = "<font color=red>An error has occurred:</font> <p>" + error;
    }

    function layoutResults(queryResult, out, startTime) {
        var timeTaken = new Date().getTime() - startTime;

        if (queryResult.size > 0) {
            var output = "";
            var records = queryResult.getArray('records');

            for (var i = 0; i < records.length; i++) {
                var account = records[i];
                output += account.Id + " " + account.Name + " [Industry - "  
                     + account.Industry + "]<BR>";
            }

            out.innerHTML = output + "<BR> <BR> query complexted in: " + timeTaken + " ms.";
        } else {
            out.innerHTML = "No records matched.";
        }
    }
    window.onload=setupPage();
</script>

</apex:page>
1
  • Riaz, one has to be careful when posting code. I've fixed your post. The first 6 lines and last 2 weren't displayed. Be sure to space over at least 4 spaces. Unfortunately, pasting all of your code in at once using the "preformatted text" braces doesn't always retain your spacing/tabbing, so best to check that in a preview pane before saving.
    – crmprogdev
    Apr 22, 2014 at 16:04
0

On button creation page choose option as URL. Which lies above the formulae box.

1
  • i selecet URL once can you check image oce in my question
    – Sathya
    Apr 22, 2014 at 8:00

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.