Log email button

I was following these instructions: Page Not Found — Skuid v15.1.6 Documentation and I am tweaking it to work with the Lead object and am running into a hiccup. When I click the button it opens fine and everything populate properly with the exception of the “Related To” section. I need the “Name” and “Related To” field to auto populate with the Lead ID. Any help would be greatly appreciated. Thank you!

Can you copy the Redirect URL property from the Action properties  so we can see how you have coded it?  

Sorry I meant to include that code. /00T/e?title=Email%3A%20&whoid={{#$Model.LeadData.data}}{{Id15}}{{/$Model.LeadData.data}}&tsk5=Email%3A%20&tsk10=Email&retURL=%2F{{$Param.id}}

Thanks.  Coding is so tough because one character will mess you up.  Instead of whoid it needs to be who_id.   In addition you are not going to get a Related To (what_id) reference on leads.  If you look at the standard task page for leads the related to field is greyed out. 

The url coudl look somthing like this: 

/00T/e?who_id={{#$Model.LeadData.data}}{{Id15}}{{/$Model.LeadData.data}}&retURL=%2{{$Param.id}}

Hi Rob, This code: /00T/e?who_id={{#$Model.LeadData.data}}{{/$Model.LeadData.data}}&retURL=%2{{$Param.id}} is somewhat close to working however I see the issue is the system is not pulling in the Lead Id. When I put the above code in for the button and test it the “id=” is blank and the “retURL id” is incorrect. When I manually put the Lead Id in for both it works perfectly. Do you know what the correct parameters would be in the url to pull in the Lead id? Thank you for all your help.

Again, so close, so close. 

This requires a lesson in the syntax merge language that we use.  Its called Mustache…

It allows you to make “if then” statements with the “#” and “/” character.   So the section 

{{#$Model.LeadData.data}}{{Id15}}{{/$Model.LeadData.data}}

Can be read “If lead data exists” then show “Id15”  “end if lead data exists”.   The other character is “^” which means - if Does Not exist. 

Your statement was:

&nbsp;{{#$Model.LeadData.data}}{{/$Model.LeadData.data}} &nbsp;<br>

Which just asked the “if” statement,  but didn’t tell the system to show any data if the condition was true.  Add the {{Id15}} and I think you’ll be golden. 

Me again. Thank you for your patience working through this issue with me and the mustache lesson. That helped it make more sense. I put the code in exactly as you instructed but the who_id is still not being pulled. When I push the “Log Email” button the url shows “who_id=&” it is not pulling in the Lead id. However when I manually put the ID in the URL it works fine. It seems the “Id15” does not pull the id. I have tried Param.id and whoid to no avail. I am not sure what else to do to get it to pull the Lead record id. Any thoughts would be greatly appreciated. Thank you!

This is funny. I think I ran into exactly the same problem in my work today… What I was doing was trying to create a “New Email” button above the “tasks” table. And I had the same experience - the Who_Id wouldn’t populate.

Then it hit me.

  1. Every skuid component is connected to a single Skuid Model - and if you just use a field name (like Id15) it will look in that model for the data.
  2. This means you have to make sure there is data in your model if you want these redirect scenarios to work.
  3. The tasks table connects to the "Tasks" model. And if no tasks have been created - there will be no data from which to retrieve the "Id15" field.
Ugh. I need to fix that tutorial...

Fortunately there is another way. The following syntax will retrieve fields from another model. {{$Model.<>.data.0.<>}}

Where - <> is the name you gave your model
and <> is the field name (Like Id15)

data.0 means - find the first row of data (you could also get the 10th if you wanted…

Hopefully this will help you get along…

We are making progress… This will be good for your tutorial too. The next issue is the “Save” and “Cancel” buttons do not work. When pushed I get a “URL does not exist " error message. I see the issue is the URL it looks like this: https://cs14.salesforce.com/0Qc0000004LPk2EAG What I don’t know is how to code the standard SalesForce “Save” and Cancel” buttons to direct back to a skuid page. Here are the codes I used for “Log a Call” and Log an Email" I had to make a slight change from your suggestion. ID15 does not bring in the Lead ID for me. Log a Call /00T/e?title=Call&who_id={{$Model.Lead.data.0.Id15}}&followup=1&tsk5=Call&retURL=%2{{$Param.id}} Log a Call Log a Email /00T/e?title=Email&who_id={{$Model.Lead.data.0.Id15}}&retURL=%2{{$Param.id}} LogEmail Hopefully all this back and forth is mutually beneficial. Thank you!

Ah yes - the back and forth is very mutually beneficial…  

Again it boils down to pesky characters.  It almost always does.  Your RetURLs are missing an F.   (I imagine you are saying “F that”.  I know I do…)   Here is the way your RetURL’s need to look:  &retURL=%2F{{$Param.id}}      See that F? 

The code “%2F”  is URL Encoding for the “/” character.   This means it gets ignored when in the rediret URL that goes to the “Log a call page”, but can be used as a parameter on that page to govern what happens when you push save.  

Here is a discussion of URL Enconding:   http://salesforce.stackexchange.com/questions/11336/url-hack-pass-additional-parameters-into-the-sav… 

Rob, I think we got it! Thank you so much for all of your help. I had to tweak the URL tag a little bit so that the tasks would automatically close. I provided the adjusted code below. Thank you again for all the help and explanations. Log a Call /00T/e?title=Call&who_id={{$Model.Lead.data.0.Id}}&followup=1&tsk5=Call&retURL=%2F{{$Param.id}} Log a Call Log a Email /00T/e?title=Email&who_id={{$Model.Lead.data.0.Id}}&tsk12=Completed&tsk5=Email&retURL=%2F{{$Param.id}} LogEmail

This benefitted me too, in a different scenario. I have a Skuid wizard that creates a prospect account, several contacts and several tasks, then does a single save and redirect at the end. I needed the redirect to go to the new account’s detail page, but the wizard doesn’t have a model context. Using your example, I was able to set the redirect to “/apex/ProspectView?id={{$Model.NewOrganisation.data.0.Id}}” and it works beautifully. I’m a fan of the mustache (although my wife really isn’t, as it makes me look like her dad c.1985).