function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
LeeCLeeC 

Button, Text Field and Checkbox

Hello, I am trying to use a URL so when I click a custom button it places a tick in a checkbox and text in a text field. It then saves the record. I am trying to use:

 

https://na6.salesforce.com/{!Opportunity.Id}/e—retURL=​%2F{!Opportunity.Id}&Opportunity.NP_New_Opp__c=1&save=1

 

Opportunity.NP_New_Opp__c is my checkbox field.

 

Once I get the Tickbox working I was going to try and add the text. Does anyone know what I am doing wrong?

 

Thanks

SporterSporter

Try using the field ID instead of the name for Opportunity.NP_New_Opp__c .

LeeCLeeC

Didnt work. Still comes up with "You have attempted to reach a URL that no longer exists on salesforce.com"

Do you have any more idea's?

 

Thanks

SporterSporter

Try the following (will need to take your values rather than mine:

 

 

https://na6.salesforce.com/{!Opportunity.Id}/e?save=1&00N20000002iTsu=1&retURL=%2F{!Opportunity.Id}

 

So replace the ID in there with your field ID instead.

 

LeeCLeeC

I replaced your "&00N20000002iTsu" with my checbox value. This time when I click the button it takes me back to the default home page but the checkbox is not ticked.

 

https://na6.salesforce.com/{!Opportunity.Id }/e?save=1&00N80000004TdG7=1&retURL​=%2F{!Opportunity.Id}

 

This is an opportunity so I guess I want to keep your Opportunity.id fields?

 

THanks again      

SporterSporter

Confirm the field ID is correct as i've tested this with a test checkbox, no spaces in the merge field either (that may just be the formatting in the forum here) .

 

What are the other options you have selected for the button in the edit page? (Is this button on the opportunity object or somewhere else?)

LeeCLeeC

Thanks - I got it working, I wasnt using the correct field ID :smileysad:

 

Would you happen to know if it’s possible to get this to Update the field then create a new record. I have got both parts working separate but when I combine them in the button the page comes back with "Insufficient Privileges - You do not have the level of access necessary to perform the operation you requested"

 

 

This is the code im using:

 

https://na6.salesforce.com/{!Opportunity.Id}/e?save=1&00N80000004TdGC=1&retURL​=%2F{!Opportunity.Id}


https://na6.salesforce.com/500/e?retURL=%2F500%2Fo&RecordType=01280000000Hdfy&ent=Case
&cas4={!Opportunity.Account}
&cas14={!Opportunity.Name}
&cas15={!Opportunity.Description}

 

I have tried removing the "&retURL​=%2F{!Opportunity.Id}" of the end of the button check code.

 

Thanks :)

 

SporterSporter

Right so I'm not fantastic with buttons but I've had a go at one here:

 

 

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

var myOpp = new sforce.SObject("Opportunity");
var a = {!Opportunity.Check_This__c};

myOpp.Id = "{!Opportunity.Id}";

if ( a == 1) { 
myOpp.Check_This__c= 0;
} 
else { 
myOpp.Check_This__c= 1;
} 


alert("You have Updated the Checkbox with: "+myOpp.Check_This__c +" it's previous value was {!Opportunity.Check_This__c}");
sforce.connection.update([myOpp]);


window.parent.location.href="https://emea.salesforce.com/500/e?cas4={!Opportunity.Account}&cas14={!Opportunity.Name}&Cas15={!Opportunity.Description}&retURL​=/{!Case.Id}";

 

Obviously the above doesn't do your operation as I've written it specifly for my test case.

 

 

 

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

var myOpp = new sforce.SObject("Opportunity");

myOpp.Id = "{!Opportunity.Id}";
myOpp.NP_New_Opp__c= 1;

window.parent.location.href="https://na6.salesforce.com/500/e?cas4={!Opportunity.Account}&cas14={!Opportunity.Name}&Cas15={!Opportunity.Description}&retURL​=/{!Case.Id}";

 

Try the above and tell me how you get on as this is a new thing for myself to try, there is probably a far better way to call the new record to the case object but I couldn't find one.

 

 

SporterSporter

Heya LeeC, did this button help with you issue?

LeeCLeeC

Hi Sporter, I was trying to figure out a way using only the html code to add the checkbox and open up a new object. I will post the solution  if I figure it out.

 

Thanks for all your help

b-Forceb-Force

Guys,

you can use URLFOR and URLENCODE standard function while construction URL, which will insure for passing correct values to next page

 

Thanks,

Bala 

LeeCLeeC

I am new to this, would you please be able to give me an example on how I could join these two commands together?

 

This Ticks the checkbox and saves the Opportunity:

https://na6.salesforce.com/{!Opportunity.Id}/e?sav​e=1&00N80000004TdGC=1&retURL​=%2F{!Opportunity.Id}

Once this code is run it saves the opportunity and takes me back to the home object.

 

This Creates my new Case and brings the info from Opportunities

https://na6.salesforce.com/500/e?retURL=%2F500%2Fo&RecordType=01280000000Hdfy&ent=Case
&cas4={!Opportunity.Account}
&cas14={!Opportunity.Name}
&cas15={!Opportunity.Description}

 

Thanks :)

 

 

 

SporterSporter

LeeC, the button code I wrote on an earlier post would do what you want , here it is modified to include the record type:

 

 

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

var myOpp = new sforce.SObject("Opportunity");
myOpp.Id = "{!Opportunity.Id}";
myOpp.Check_This__c= 1;


window.parent.location.href="https://na6.salesforce.com/500/e?save=1&RecordType=01280000000Hdfy&cas4={!Opportunity.Account}&cas14={!Opportunity.Name}&Cas15={!Opportunity.Description}&retURL​=/{!Case.Id}";

 

You'll need to change the myOpp.Check_This_c in the javascript to the API name of the checkbox field (in this example it is a checkbox but you could apply it to any field).

 

I know you want the URL version of it with merge fields etc but be aware this is a URL hack and if something were to go wrong and you contacted salesforce support they wouldn't help you with it.

 

Looking into combining the two urls I don't think it's possible in the way you want it as every time i've attempted to use a URL hack I run into trouble with one thing or another.