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
AdrianaAdriana 

Creating custom buttons.

Hi,
I've never created a custom button, and I have created 3 different objects (Listing, offer and closing) I'd like to be able to convert the listing into an offer and then the offer into a closing. Something similar as the standard convert objects in leads and opportunities. Any ideas on how I could do it?
 
Thanks in advance,
 
Adriana.
kMans2kkMans2k
Hey,

I am also a newbie and attempting to do something similar.

1st step is for you create a custom s-control with the following code:

<script language="JavaScript">
function redirect() {
var url = "/a07/e?retURL=%2F{!Listing__c.Id}"+
"&00N70000001xm30={!Listing__c.Name}";
parent.frames.location.replace(url);
}
redirect();
</script>

In this script "a07" is like a ID for the object you are creating. You can find this by selecting the custom object tab and then click "new".  Then look at the URL. eg:
https://na5.salesforce.com/a07/e?retURL=%2Fa07%2Fo

the code for the object should be after ".com/"

"retURL=%2F{!Listing__c.Id}" bit lets you return to the Listing you were viewing after you've saved the Listing.

"&00N70000001xm30" is the id for input field in the Offer page. To get these go to the create new Offer page and choose view source. The ID's will show up. "{!Listing__c.Name}" is the field from Listing you want to pass to the Offer object.

What you'll have to do is to create a custom button and call it "Convert Listing". Choose "s-Controls" as a source.

It's not exactly a conversion, but it does pass information through. I'm having trouble with picklists though. i cannot seem to pass the value of picklist fields from the details page.
AdrianaAdriana

Hi,

Thanks for your quick reply. I really appreciate it.

Wow!!! By new, I mean new, haha :smileyhappy: I've created custom objects, but have never dealt with S-Controls and really know nothing of programming.

However, I studied your post and understood all the logic behind it. I did everything as you detailed:

I created a custom S-Control with the following info:

<script language="JavaScript">
function redirect() {
var url = "a01/e?retURL=%2F{!BLUE_Listings__c.Id}"+
"&00N50000001mEYO={!BLUE_Listings__c.Name}"; 
parent.frames.location.replace(url);
}
redirect();
</script>

Then I created a custom button at the listing layout, but when I do click on it I get a message URL No Longer Exists

Any idea of where I could be going wrong?

Thanks so much for your input!!

 

kMans2kkMans2k
don't worry; I am an absolute newbie to Salesforce as well.

One thing I can notice from your code is that the leading backslash is missing. see:
var url = "a01/e?retURL=%2F{!BLUE_Listings__c.Id}"+

When you create the S-Control create it as a "html", and then link it to it... I have had trouble with snippets.

Other than that double check the field Id's, but don't think that's the cause of problem here.

See how you go.
AdrianaAdriana
Hi,
Thanks for your time. I corrected the slash and it worked!!! Next question, can I put more fields in the same S-Control or do you have to create an S-Control for every field that you need to copy the information from. For example, I now have two fields that I'd like to update:
 
<script language="JavaScript">
function redirect() {
var url = "/a02/e?retURL=%2F{!BLUE_Listings__c.Id}"+
"&00N50000001mEYO={!BLUE_Listings__c.Name}";
parent.frames.location.replace(url);
}
redirect();
</script>

<script language="JavaScript">
function redirect() {
var url = "/a02/e?retURL=%2F{!BLUE_Listings__c.Id}"+
"&00N50000001mLcM={!BLUE_Listings__c.Construction_m2__c}";
parent.frames.location.replace(url);
}
redirect();
</script>
 
Thanks so much for your time and responses!!