Custom Button to copy data from Opportunity into a related custom object - salesforce

I have a custom object that is used for product setup that is mapped to an opportunity. It's a one to many relationship - one opportunity maps to many setup objects, but one setup object is only mapped to one opportunity.
Opportunity has some setup fields that need to act as defaults for the related custom object. Unfortunately, I cannot just specify them in a formula - getting an error.
What I would like to do is have a custom button that would allow user to click and copy all of the related setup fields from the opportunity into the custom setup object and then edit them as needed.
Any pointers or sample code are greatly appreciated!

You can achieve this with a custom button on the related list for your custom object on the opportunity detail page.
All of the fields on a standard Salesforce new/edit screen have id's associated with them. You can specify values for fields by using these ids to set GET parameters on your URL. For example if the id on the name field on your opportunity is 'opp3', the following URL will populate the name field on your new opportunity page:
https://na2.salesforce.com/006/e?opp3=Hello+World
You would have to change na2 to the correct server for your org.
The new record page URL contains the 3 character id prefix for your particular object and then '/e'. 006 is the prefix for opportunities. You will have to attempt to create a new record to see what the 3 characters are for your custom object.
You will have to capture the id's of the fields you want to populate on your custom object. You can do this by viewing the source of the new record page. For custom fields these id's will take the form of a Salesforce Id (eg. 00N40000002QhEV).
Create a new list button on your custom object and set the behavior to without header and sidebar and set the source to URL. Build up your URL with id=value pairs separated by '&' using the id you got from the page source and the insert field functionality to select the opportunity fields your wish to add in. You should end up with something like this:
/a0U/e?00N40000002QhEV={!Opportunity.Name}&00N40000002QhEW={!Opportunity.StageName}
a0U should be replaced by the correct prefix for your custom object. Then add your button to the related list for your custom object under opportunity.

Related

How do I get the lookup objects field history tracking to show up in the related list of the child object?

I can see in my org that someone has a lookup to opportunity and can get the history tracking of opportunity in the related list of the custom object.
I tried to do it for another custom object and it didn't work.
To replicate this in a scratch org I created two custom objects custom object 1 and custom object 2.
Custom object 2 has a lookup to custom object 1 and I made a field "status" on 1 and turned on the field history tracking on it. While creating the objects object 1 didn't have field history tracking turned on and I turned it on but in the real org its turned on from what I can see.
Here is what I can see. As I have field history tracking turned on for both 1 and 2 I can see history object for both in their respective page layouts under the related tabs.
What I want to see is Custom object 1 's history on custom object 2 under the related list but I can't get it to show up. I can see that people have been successful in my org in doing so.

How to avoid placing fields everytime a contract is generated with DocuSign Gen and DocuSign Envelope in Salesforce?

I have the following scenario that I need to put in place:
A user from SF must generate a contract with tables for a customer. As soon as the contract is generated, the user will handle the contract in a tablet to the customer, so he can sign it off in person.
To implement this I'm using DocuSign Gen to generate a template, because this particular template needs to have a table with multiple rows. So:
I declared all the Salesforce Fields I'm using on the contract .
I placed all the anchor texts on the MS Word file.
I declared all the DocuSign Fields (i.e. Signature, Name, Date Signed).
I also placed them all their anchor texts at the bottom of the MS Word file.
Finally, I selected a DocuSign Envelope (check the description below) template to streamline the signature delivery.
For the DocuSign Envelope, I simply created a template, but I didn't select any document, since that was going to be handle by the DocuSign Gen template. I defined the recipients (In Person Signer), and for the sending experience I selected the option Send Now: Skips all controls and sends the envelope immediately.
So, I was expecting that after clicking on the DocuSign Gen template button, the contract will be sent to the user so, he can handle the contract to the customer, to sign it directly.
Instead, after the contract is sent, and the user handled the control to the customer, they need to place AGAIN the DocuSign Fields (i.e. Signature, date, name) on the contract before signing it off.
How can I avoid that? I want neither the user nor the customer to place the fields again, since that's already defined on the template created on DocuSign Gen already.
It’s absolutely possible to set up an eSignature Envelope Template Configuration that works with anchor-tag/autoplacement, either with or without a static document pre-uploaded into the template. There are default anchor fields we offer out of the box that are listed in this support article. But it’s also possible to create your own custom merge fields with defined anchor text with the {r} wildcard placeholder.
The trick is to also ensure your recipients use the standard role naming conventions of “Signer 1”, “Signer 2", etc.
Example:
If you have \s1\ on the document, then that will get assigned to the recipient you’ve defined with the role name of “Signer 1”.
\s2\ for “Signer 2.” etc.
If you create a custom field with the defined anchor text of something like \ObjectName_FieldName_{r}\
Then on the document you place the text as \ObjectName_FieldName_1\
That field would be assigned to “Signer 1”
\ObjectName_FieldName_2\ would be assigned to “Signer 2" etc.
More information can be found here - https://support.docusign.com/s/document-item?language=en_US&bundleId=srl1586134368658&topicId=rvg1644270913133.html&_LANG=enus
From what I can tell, linking an Envelope Template to a Gen Template renders the Gen Template useless. I can't find any clear documentation about how they are supposed to be used together.
This is what I did:
Created a Gen Template with a Word document that has all of my anchors.
I wanted the Recipients to be auto-populated, so I also created an Envelope Template (without a document) and linked it to the Gen Template.
I expected that when I clicked the Gen Template button, it would use my tagged template, auto-choose the recipients, and send. However, as you stated, you have to replace all of the fields. I have no idea why.
I tried #inbar's suggestion of using autoplacement. I created a new document with these tags and uploaded it to the Envelope Template. This works as expected, but it seems to render the Gen Template useless.
At this point, I think the best route is to not use a Gen Template and just use an Envelope Template with autoplacement. I wish the documentation was more clear about how to use these templates together.

Sales Force sending email to non user with template from custom object

I'm need to create email in Sales Force with the recipient as a custom object rather than a User, Contact or Person. Unfortunately, it appears my client has created a custom object for the entity we need to contact.
I tried several methods in the UI and they have all ended up needing a User or Contact record to succeed.
I'm now using APEX code in a trigger, it also requires a User, but I have managed to get past that using this work around: Sending Emails in Salesforce to Non-Contacts Using Apex
Now I need to pass my custom object into the Email Template to get the merge fields from it.
I believe setWhatId is the correct approach, but it returns "Invalid entity type for whatId".
Not sure where to turn now....
In short, I have a custom object that is not a user or a contact, but it does have a related custom object with an email address field (also not user or contact).
I need to send an email to the email address recorded on the related custom object passing the custom object to the template to gain its merge fields.
Any help or guidance would be much appreciated. Can I even do this?
Best Regards,
Rod
From your comment and without knowing much more, the relationship traversal should look like this:
Contact c = [select id, Email from Contact where id=q.Client__r.Participant_Portal_Contact__r.id limit 1];
Assuming that the email address field is on a parent object you dont need to do this with code you can probably do this using a Visualforce Email template and the relatedTo set to the object with the details you want to use as merge fields. That way you can use it in workflow or process builder or flows without the need for code

Docusign Formatting and Salesforce integration issue

I am in a Salesforce environment and trying to send out a docusign document using Docusign and Conga. I am using a 30 day trial.
1.Using Conga and Docusign works very well together and the formatting is correct except that I need to have 2 radio buttons on the form. Is there a way to add anchor tags to my Word document and hide them(white text) like I do for the Docusign signature and date tags?
I tried following the documentation for creating the radio buttons in Docusign and tie them to a picklist field in Salesforce but I have yet been able to write back to Salesforce.
How do you control the text length for a Docusign template? I have fields that make up the address but the spacing is not dynamic so depending on the field value the text may run into each other. Is there a way to have the fields adjust based on field value length?
How do I show multiple related records? I have a case with multiple activities associated to it and I need to display them. In Conga I use a table and all of the records show. But if I create a docusign template it is only showing the first record.
If at all possible I would prefer to add the anchor tags to the existing document since the formatting is cleaner.
Michael
There is. You'll want to avoid applying anchor tags directly to a DocuSign template when working in the web console. The reason for this is that when you're sending from Salesforce with or without Salesforce anchor strings you're going to receive an error message indicating that there's no text associated with an anchor string.
You can accomplish this through Custom Fields inside of Salesforce.
Basically, you place your text in white where you want the tag to attach to your document. You'll want to set the anchor string in the format of \variable{r}\ on the tag, then in the underlying document you would replace {r} with the recipient number in the signing order.
IE: \variable_{r}\ becomes \variable_1\, when Salesforce picks this up it will tag the document automatically. For more information, see here: https://support.docusign.com/guides/dfs-user-guide-use-automatic-anchor-text-with-custom-tags-user.
In terms of writing back the value of a Radio Button, as I'm sure you've noticed this can be tricky. The values for the picklist in Salesforce need to match up exactly, then be written back by adding a new line in your Connect object. A step by step guide is available on the support site: https://support.docusign.com/articles/DocuSign-for-Salesforce-How-to-update-a-Salesforce-Field-with-a-DocuSign-Radio-Button-Value.
The Width of a text field is determined in one of a few ways:
1) You can supply a fixed size in the API call being used to generate them.
2) You can save the custom field inside of DocuSign as a Custom Field after setting the width to it.
3) Set the Fixed Size flag to false, then the text field should fill itself out when text is applied to it.
Would you mind being more specific in regards to the status record?

Sales-force Custom Object Edit page layout and Button

We have a custom object say Sales form. On edit apge of customer object we need to add a button Save and Add Product(similar to One we can have on Opportunity page). User forget to add Product/SKU after saving the sales form
New Button(Save and Add product), will save the sales-form first and then depends on record type will open the related list(child object).
Say a Sales form is for Custom Program, after save,. it will open up Custom Program relate list.
If Record type is of Price Change Notification it willl open up related list of SKU detail..
Is this possible, please adivse, we have 9-10 different record type, and we don't want to re-write the application with visualforce and all customization. Re-writing with Visualforce page has some pitfalls.
As far as I'm aware, you can't replace the Save button as it's part of the Edit page and not the standard layout, so to achieve this with one button you'd need to write a custom visualforce page, this need not be complicated though — a simple custom controller which uses a standardController for management of the record would suffice.
You would call Save on the StandardController and then return a different page redirect based on the record type, the page itself would pretty much only consist of an <apex:detail> tag. If you want more details I can provide more.
If you really don't want to write any custom code or pages then you'll need to do this as a two step process, i.e. use the standard page and then have a custom "Continue" button which takes the user onto a custom URL based on the record type. I've just created a contrived version of this by doing the following:
1 - Define a custom formula field on the object, this should be of type text and can use a CASE() statement to determine the URL which the user will be taken to when hitting the button (note that this was made just for the sake of an example so it forwards to the accounts standard page for the record type 'Friend' and contacts page for 'Foe').
CASE($RecordType.DeveloperName, 'Friend', '../001/o', 'Foe', '../003/o', '')
Note the reason I use a formula field here instead of the doing this in the custom button is that for some reason you can't seem
access the record types by name when defining a custom button.
2 - Define a custom button for the object called "Continue" or something similar that makes sense for you. For my example I just used the Contact object, so I referenced the custom field on my record and specified the options shown here:
3 - Customise the page layouts used by your record types to include this new button and you should be done!

Resources