• TimS
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Struggling with how to make an update to a date field on the Contact object when a related child object is edited and meets specific conditions. Here are the details...
Custom object Requests has a lookup field back to Contact object. A single Contact can be related to MANY requests. When a Request record is edited to meet specific values (status=Complete, etc) have a working Process that fires and distributes an email alert whihc is a suvey Invitation. At that time, I also need to update the related Contact record field, Last Survey Invite Date, with the current date.  I assume  many- to-one relationship of Requests to Contacts is why Process builder, workflow or anything else doesn't give me access to the Contact field to update.  I suspect this will require a trigger and corresponding apex class to make happen, but that's above my skill set.  Great at declarative development, but not at coding.  Any suggestions/corrections/clarifications would be appreciated.  Thanks!     
  • January 27, 2016
  • Like
  • 0
Using a custom button as written below to set value of a custom object (Request__c) picklist field (Status__c) to "Rejected." Need to modify so it validates any value has been entered in another picklist field (Reject_Reason__c). If no value is selected in Reject_Reason__c, then alert needs to appear instructing user to select a value and status field is NOT updated to "Rejected," as Status__c should only be set to "Rejected" if any value has been selected in Reject_Reason__c
 
{!requireScript("/soap/ajax/26.0/connection.js")} 
var request = new sforce.SObject("Request__c"); 
request.id = "{!Request__c.Id}" 
request.Status__c = 'Rejected'; 
sforce.connection.update([request]); 
window.location.reload(); //to reload the window and show the updated values
 
I've tried modifying but to no end as I am not vered in javascript at all. Anyone's assistance would be greatly appreciated!  Thanks!
  • November 11, 2015
  • Like
  • 0
Have a custom object (Customer Comment) to capture customer comments, containing lookup fields to both Contact and Account objects. Need to add a new comment from a Contact record, which standard "New" button populates the related Contact but not the related Account. So want to replace the standard "New" button on the custom object's related list on a contact record with a custom javascript button that will populate BOTH the custom object's related Contact and Account lookup fields with the related records.

Not a developer by trade, so using some code created by a former employee which did something similar with other obejcts, but am obviously missing something. The code below generates the error "Cannot read property 'Id' of undefined."

Here's the code...any assistance to this novice would be greatly appreciated...relaize it is probably something simple, but yet over my head and am running out of time.  HELP!!!!  Thanks in advance.....

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

//Used to trim the last three characters off of the Profile Id's in txtProfileId1, //txtProfileId2 and txtProfileId3 
function Left(str, n){ 
if (n <= 0) 
return ""; 
else if (n > String(str).length) 
return str; 
else 
return String(str).substring(0,n); 


var txtContact__c = "00NC0000006Epxb"; //SFDC ID of Contact__c custom field in Customer Comment object 
var txtAccount__c = "00NC0000006Epxg"; //SFID of Account__c custom field in Customer Comment object 
var txtObjPrefix = 'a2k'; //Three-letter prefix for Customer Comment custom object 
var txtContactId__c ="{!Contact.Id}"; //Related Contact SFDC Id 
var txtCustCommentName = "{!Customer_Comment__c.Name}"; //Customer Comment Name 
var txtAccount = "{!Customer_Comment__c.Account__c}"; //Related Account 
var txtAccountID = ""; //Account Id 

var txtAccountIdResult = sforce.connection.query("SELECT Id FROM Account WHERE Name = '" + txtAccount + "'"); 
txtAccountId = Left(txtAccountIdResult.getArray("records")[0].Id, 15); 

//Open a new Customer Comment record to add a new comment to a Contact that also populates the related Account lookup 
parent.location.href = "/" + txtObjPrefix + "/e?CF" + txtContact__c + "=" + txtCustCommentName + "&CF" + txtContact__c + "_lkid=" + txtContactId + "&CF" + txtAccount__c + "=" + txtAccount + "&CF" + txtAccount__c + "_lkid=" + txtAccountId + "&retURL=%2F" + txtContactId;
  • March 11, 2015
  • Like
  • 0
I need some help with javascript code for custom button to update a field on a record so a workflow rule is executed that then sends an email alert. I have a checkbox field to update but as I am not versed very well in code to update it, need some assistance. Does anyone have some code to accomplish this yoy can share? Thanks.
  • October 28, 2014
  • Like
  • 0
Struggling with how to make an update to a date field on the Contact object when a related child object is edited and meets specific conditions. Here are the details...
Custom object Requests has a lookup field back to Contact object. A single Contact can be related to MANY requests. When a Request record is edited to meet specific values (status=Complete, etc) have a working Process that fires and distributes an email alert whihc is a suvey Invitation. At that time, I also need to update the related Contact record field, Last Survey Invite Date, with the current date.  I assume  many- to-one relationship of Requests to Contacts is why Process builder, workflow or anything else doesn't give me access to the Contact field to update.  I suspect this will require a trigger and corresponding apex class to make happen, but that's above my skill set.  Great at declarative development, but not at coding.  Any suggestions/corrections/clarifications would be appreciated.  Thanks!     
  • January 27, 2016
  • Like
  • 0
Using a custom button as written below to set value of a custom object (Request__c) picklist field (Status__c) to "Rejected." Need to modify so it validates any value has been entered in another picklist field (Reject_Reason__c). If no value is selected in Reject_Reason__c, then alert needs to appear instructing user to select a value and status field is NOT updated to "Rejected," as Status__c should only be set to "Rejected" if any value has been selected in Reject_Reason__c
 
{!requireScript("/soap/ajax/26.0/connection.js")} 
var request = new sforce.SObject("Request__c"); 
request.id = "{!Request__c.Id}" 
request.Status__c = 'Rejected'; 
sforce.connection.update([request]); 
window.location.reload(); //to reload the window and show the updated values
 
I've tried modifying but to no end as I am not vered in javascript at all. Anyone's assistance would be greatly appreciated!  Thanks!
  • November 11, 2015
  • Like
  • 0
I need some help with javascript code for custom button to update a field on a record so a workflow rule is executed that then sends an email alert. I have a checkbox field to update but as I am not versed very well in code to update it, need some assistance. Does anyone have some code to accomplish this yoy can share? Thanks.
  • October 28, 2014
  • Like
  • 0