• sfdcChi2
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 23
    Replies
I use the below javascript button to auto populate recipients from a custom object called RvMembers (similar to the contact object) on the related list of the RVAccount (similar to the account object) when sending documents for signature using docusign. 
Problem is it works if there are more than one member in the related list but it does not populate if there is only one member in the related list. I believe it has to do with the query but i'm new to javascript so need help asap.


{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}

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

//********* Option Declarations (Do not modify )*********//
var RC = '';
var RSL='';
var RSRO='';
var RROS='';
var CCRM='';
var CCTM='';
var CCNM='';
var CRCL='';
var CRL='';
var DST='';
var LA='';
var CEM='';
var CES='';
var STB='';
var SSB='';
var SES='';
var SEM='';
var SRS='';
var SCS ='';
var RES='';
var OCO='';
var debug = false;

//*************************************************//
/* Encode all variables from data with left brace bang URLENCODE( bang JSENCODE(salesforceobject.salesforcefield))}  */



function foundRVAccountAnyMembers()
{

      var RVAccountAnyMembers = 'Not Found';
     
      try
      {
       var result = sforce.connection.query("Select id, (Select Id, Name, rvpe__Email__c, rvpe__ExtMemberId__c, rvpe__FirstName__c, rvpe__LastName__c, rvpe__RVAccount__c From rvpe__RVMembers__r  ) From rvpe__RVAccount__c r where id = '{!rvpe__RVAccount__c.Id}' LiMIT 1");
      
       var records = result.getArray("records");
      
       if (records.length != 0)
       {
      
      RVAccountAnyMembers = 'Records Found';
       }
    }
    catch(error)
    {
     if (debug)
     {
      alert('Exception Name: '+error.name+ 'Exception Message:' + error.message);
     }
    }
    finally
    {
     if (debug)
     {
      alert('Finally - foundRVAccountAnyMembers: RVAccountAnyMembers = '+RVAccountAnyMembers);
     }
    }
              
               return RVAccountAnyMembers;
}


function getMembersInfoasCRL()
{

    
       try
       {
       var result = sforce.connection.query("Select id, (Select Id, Name, rvpe__Email__c, rvpe__ExtMemberId__c, rvpe__FirstName__c, rvpe__LastName__c, rvpe__RVAccount__c From rvpe__RVMembers__r  ) From rvpe__RVAccount__c r where id = '{!rvpe__RVAccount__c.Id}' LiMIT 99");
      
       var records = result.getArray("records");
                                   for(recs1 = 0; recs1 <100; recs1++ )
                                   {
       var RVMembers = records[recs1].get("rvpe__RVMembers__r");
              var contact = RVMembers.get("records");

       for(recs = 0; recs <100; recs++ )
                                     
       {
    
      var contactEmail = contact[recs].rvpe__Email__c;
      var contactFirstName = contact[recs].rvpe__FirstName__c;
      var contactLastName = contact[recs].rvpe__LastName__c;

      if(contactEmail==null)
      {
       alert('Member is missing email, correct and then send again');
       return;
      }
      if(contactFirstName==null)
      {
       alert('Member is missing FirstName, correct and then send again');
       return;
      }
      if(contactLastName==null)
      {
       alert('Member is missing LastName, correct and then send again');
       return;
      }
    
      CRL=CRL+'Email~'+contactEmail+';FirstName~'+contactFirstName+';LastName~'+contactLastName+';,';
     
       }
                                  }
    }
    catch(error)
    {
     if (debug)
     {
      alert('Exception Name: '+error.name+ 'Exception Message:' + error.message);
     }
    }
    finally
    {
     if (debug)
     {
      alert('Finally - getMembersInfoasCRL: CRL = '+CRL);

     }
    }
              
               return ;
}

function getDataForDocuSign()
{

var RVAccountAnyMembers = foundRVAccountAnyMembers();

if(foundRVAccountAnyMembers=='Not Found')
{
  return;
}
else
{
  getMembersInfoasCRL();
 
  if(CRL=='')
  {
   return;
  }
}



var newLocation ="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!rvpe__RVAccount__c.Id}&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;
//********* Page Callout (Do not modify) *********//
if (debug) {
  alert(newLocation);
} else {
  window.location.href = newLocation;
}
}

//*******************************************//

getDataForDocuSign();
I have a checkbox field named primary_contact__c in the Contact object. I want an individual contact to be the only primary contact for any given account. hence once the checkbox field is checked for an individual account i want to prevent any other individual contact from having the same field checked for the same account. an attempt to do this should result in an error. 
Can somebody please help with this. I'M thinking the only way to do this is with a trigger
Can anyone help with a sample code that can autopopulate a lookup field from a text field on the same object (lead) upon creation

Both the text field and the lookup field are on the lead object. While creating a new lead, we have the value of the text field written from an external source and we want to write that same value into the lookup field.

thank you
I'm trying to write a test class on the code below. However i can only achieve 66% as i cannot insert the UserTeamMember object with a dml statement.  The 2 lines of code marked  as No Code Coverage are the only lines not covered and mainly because i can't insert the object. would appreciate any help . thanks !!!

trigger SSSUpdate on User (before Update)
{

Map<Id,Id> mapUserTeamIdVsuserId = new Map<Id,Id>();
for(UserTeamMember u :  [SELECT id,UserId,ownerid, User.Name FROM UserTeamMember where TeamMemberRole= 'Sales Support Specialist' AND OwnerId IN:Trigger.New]){
  mapUserTeamIdVsuserId.put(u.OwnerId,U.UserId);     (No  CODE COVERAGE)
}

for(User u1 : Trigger.New){
  if(mapUserTeamIdVsuserId.containsKey(u1.id)){
   u1.SSS__c= mapUserTeamIdVsuserId.get(u1.id);          (NO CODE COVERAGE)
  }
}
}

trigger SSSUpdate on User (before Update)
{

For (User u1 : Trigger.New)
{
UserTeamMember u =  [SELECT UserId, User.Name FROM UserTeamMember where TeamMemberRole= 'Sales Support Specialist' 
AND OwnerId=:u1.ID];

u1.SSS__c= u.UserId;
}
}

trigger SampleTriggger on User (before Update)
{

For (User u1 : Trigger.New)
{
UserTeamMember u =  [SELECT UserId, User.Name FROM UserTeamMember where TeamMemberRole= 'xxx' 
AND OwnerId=:u1.ID];

u1.SSS__c= u.UserId;
}
}
I have a checkbox field named primary_contact__c in the Contact object. I want an individual contact to be the only primary contact for any given account. hence once the checkbox field is checked for an individual account i want to prevent any other individual contact from having the same field checked for the same account. an attempt to do this should result in an error. 
Can somebody please help with this. I'M thinking the only way to do this is with a trigger
I have a checkbox field named primary_contact__c in the Contact object. I want an individual contact to be the only primary contact for any given account. hence once the checkbox field is checked for an individual account i want to prevent any other individual contact from having the same field checked for the same account. an attempt to do this should result in an error. 
Can somebody please help with this. I'M thinking the only way to do this is with a trigger
Can anyone help with a sample code that can autopopulate a lookup field from a text field on the same object (lead) upon creation

Both the text field and the lookup field are on the lead object. While creating a new lead, we have the value of the text field written from an external source and we want to write that same value into the lookup field.

thank you
I'm trying to write a test class on the code below. However i can only achieve 66% as i cannot insert the UserTeamMember object with a dml statement.  The 2 lines of code marked  as No Code Coverage are the only lines not covered and mainly because i can't insert the object. would appreciate any help . thanks !!!

trigger SSSUpdate on User (before Update)
{

Map<Id,Id> mapUserTeamIdVsuserId = new Map<Id,Id>();
for(UserTeamMember u :  [SELECT id,UserId,ownerid, User.Name FROM UserTeamMember where TeamMemberRole= 'Sales Support Specialist' AND OwnerId IN:Trigger.New]){
  mapUserTeamIdVsuserId.put(u.OwnerId,U.UserId);     (No  CODE COVERAGE)
}

for(User u1 : Trigger.New){
  if(mapUserTeamIdVsuserId.containsKey(u1.id)){
   u1.SSS__c= mapUserTeamIdVsuserId.get(u1.id);          (NO CODE COVERAGE)
  }
}
}

trigger SSSUpdate on User (before Update)
{

For (User u1 : Trigger.New)
{
UserTeamMember u =  [SELECT UserId, User.Name FROM UserTeamMember where TeamMemberRole= 'Sales Support Specialist' 
AND OwnerId=:u1.ID];

u1.SSS__c= u.UserId;
}
}

trigger SampleTriggger on User (before Update)
{

For (User u1 : Trigger.New)
{
UserTeamMember u =  [SELECT UserId, User.Name FROM UserTeamMember where TeamMemberRole= 'xxx' 
AND OwnerId=:u1.ID];

u1.SSS__c= u.UserId;
}
}
Hello,

I just made this formula and thought it could save someone in the future some time.  Entering this into a formula field will give you the full state name based on abbreviation, just do a simple find and replace for "Field" in excel to edit the formula for your specific need.

if(Field='AL','Alabama',if(Field='AK','Alaska',if(Field='AZ','Arizona',if(Field='AR','Arkansas',if(Field='CA','California',if(Field='CO','Colorado',if(Field='CT','Connecticut',if(Field='DE','Delaware',if(Field='FL','Florida',if(Field='GA','Georgia',if(Field='HI','Hawaii',if(Field='ID','Idaho',if(Field='IL','Illinois',if(Field='IN','Indiana',if(Field='IA','Iowa',if(Field='KS','Kansas',if(Field='KY','Kentucky',if(Field='LA','Louisiana',if(Field='ME','Maine',if(Field='MD','Maryland',if(Field='MA','Massachusetts',if(Field='MI','Michigan',if(Field='MN','Minnesota',if(Field='MS','Mississippi',if(Field='MO','Missouri',if(Field='MT','Montana',if(Field='NE','Nebraska',if(Field='NV','Nevada',if(Field='NH','New Hampshire',if(Field='NJ','New Jersey',if(Field='NM','New Mexico',if(Field='NY','New York',if(Field='NC','North Carolina',if(Field='ND','North Dakota',if(Field='OH','Ohio',if(Field='OK','Oklahoma',if(Field='OR','Oregon',if(Field='PA','Pennsylvania',if(Field='RI','Rhode Island',if(Field='SC','South Carolina',if(Field='SD','South Dakota',if(Field='TN','Tennessee',if(Field='TX','Texas',if(Field='UT','Utah',if(Field='VT','Vermont',if(Field='VA','Virginia',if(Field='WA','Washington',if(Field='WV','West Virginia',if(Field='WI','Wisconsin',if(Field='WY','Wyoming','Other'))))))))))))))))))))))))))))))))))))))))))))))))))

Have a great day!

I'm just getting into a SF admin seat so I don't have much Apex experience.

 

I want 2 fields in the opportunities object to be updated once a field in a custom object is updated.

 

When the text field in Object 1 (the custom object) is entered as complete, I need two seperate fields in the opportunity object updated.

 

I want status changed to approved and a custom checkbox to go from unchecked to checked.

 

Thanks in advance

Hi All,

 

 

On the Proposal__c object page i have two lookup fields.. one for Resource_Requirement__c object and another for  RR__c object. while creating the new proposal as i'll select the value for Resource_Requirement__c object.. using the lookup field..i should be able to view all the RR__c records related to selected value of Resource_Requirement__c on the visualforce page.... 

 

 

public class AllRRs
{
    private Resource_Requirement__c rrdetail;
    public List<RR__c> propdetail;
       
    public AllRRs(ApexPages.StandardController controller)
    {
        rrdetail=(Resource_Requirement__c)controller.getre​cord();
        propdetail = new List<RR__c>();
        RR__c rrlist = new RR__c();
        rrlist.RRF__c = rrdetail.id;
        propdetail.add(rrlist);                        
    }
   
    public RR__c[] getCaseRecords()
    {
        RR__c[] rrdetail = [select id,name,gPAC__c,RRF__c,Long_Term_Resource_Location​__c,Priority__c,Required_Skill__c,RR_Status__c,RM_​Phase__c from RR__c where RRF__c =:rrdetail.id];
        return rrdetail;
    }
}