• Rajasree Jayaraj
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies

Hello,

I am figuring out ways to replace our javascript buttons to lightning compatible one. We have quite a lot of javascript button one of which is "Send with Docusign" that lets a user send a contract using Docusign. I'm calling the right docusign template using this custom button & passes some parameters like recipient email. I have a part of code that validates if the contract is approved by the leads before it could be sent to client with docusign. Something like this:

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

var contrObj = new sforce.SObject("Contract"); 
contrObj.id = "{!Contract.Id}"; 
var ContrStatus="{!Contract.Contract_Status__c}"; 
var profile ="{!User.Profile}"; 

if(ContrStatus!='Approved') 

alert("The contract should be approved before sending for signature"); 

else{ 
window.location.href = '/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Contract.Id}&CRL=Email~{!Contract.Business_Contact_Email_Formula__c};FirstName~{!Contract.Business_Contact_First_Name__c};LastName~{!Contract.Business_Contact_Last_Name__c},.....................'; 
}

Now, I need to replace this javascript button with components that are lightning compatible (since we are plannign to switch to Lightning) . I'd like to know what are the possible options?

Thank you very much in advance!

Hi There,

I am trying to add a user called Account Manager (custom lookup field to User under Account) under the Account Team with Edit permission to Account, Opportunity, Contact. I tried to automate this via apex trigger on Account.

Here's my method called on Update:

public void insertAccTeamShare(List<account>newObjects,List<Account>oldObjects,Map<id,account>newMap,Map<id,account>oldMap)
  {
      List<AccountTeamMember> newmembersList = new List<AccountTeamMember>(); //list of new team members to add 
      List<AccountShare> newShareList = new List<AccountShare>(); //list of new shares to add 
      String accountAccessLevel = 'Edit', opportunityAccessLevel = 'Edit', caseAccessLevel = 'Edit',ContactAccessLevel='Edit';
      List<AccountTeamMember> deleteMemberList = new List<AccountTeamMember>();
      List<AccountShare>deleteShareList = new List<AccountShare>();
      Set<Id>updatedAccId = new set<ID>();
    for(account nAcc:newObjects)
    {
          if(nAcc.Account_Manager__c!=null)
                {
                 system.debug('AM='+nAcc.Account_Manager__c);
                   AccountShare accShare = new AccountShare();
                   accShare.AccountId=nAcc.id;
                   accShare.UserOrGroupId=nAcc.Account_Manager__c;
                   accShare.AccountAccessLevel=accountAccessLevel;
                   accShare.OpportunityAccessLevel=opportunityAccessLevel;
                   accShare.CaseAccessLevel = caseAccessLevel;
                   accShare.ContactAccessLevel = ContactAccessLevel;
                   newShareList.add(accShare);  
            
                   AccountTeamMember Teammemberad=new AccountTeamMember(); 
                   Teammemberad.AccountId=nAcc.id;
                   Teammemberad.UserId=nAcc.Account_Manager__c;
                   Teammemberad.TeamMemberRole = 'Account Manager'; 
                   newmembersList.add(Teammemberad); 
                   updatedAccId.add(nAcc.id);
               }  
            else{
                 updatedAccId.add(nAcc.id);
            }
           } 
        if(updatedAccId.size()>0)
        {
        deleteMemberList = [select id,AccountId from AccountTeamMember where AccountId=:updatedAccId];
        }
    List<AccountTeamMember>deleteMember = new List<AccountTeamMember>();

    if(deleteMemberList.size()>0)
    { 
     for(AccountTeamMember delMember: deleteMemberList)
     {  
         deleteMember.add(delMember);
     }
    }

    if(deleteMember.size()>0)
    {   try{
         delete deleteMember;
         }
       catch(Exception e){
          e.getmessage();
          system.debug('Exception HEREEEE');
      }    
    }

    if(newmembersList.size()>0 && newShareList.size()>0)
    {
       try{
          insert newmembersList;
          insert newShareList;
          }
      catch(Exception e){
          e.getmessage();
          system.debug('Exception HEREEEE');
      }
    }
  }


In the debug log I can see that Account Team member is getting inserted with Edit access, but when I check from the account, I see that the member got inserted with Read-Only & Private access.

Not sure if the record is getting rolled back and if so what could be the reason.

Any help here would be appreciated.

Thanks a lot!

Hi there,

I have a batch class that checks if a field "Tax ID validation status" is invalid and sends reminder to the Account Owners. My batch basically checks a checkbox and I have a  Worflow rule to trigger email alert when this checkbox is true:

global class InvalidVATReminderBatch implements Database.batchable<sObject>,Schedulable{
 public String query;
    global Database.QueryLocator start(Database.BatchableContext bc){
        return database.getQuerylocator('Select id,Tax_ID_Validation_Status__c,recordtypeId from Account');
    } 
    
   global void execute(Database.batchableContext info, List<Account> accnt){ 
   list<Account>AccList = [Select id,InvalidVATReminder__c,Tax_ID_Validation_Status__c,recordtypeId,recordtype.name from Account where Tax_ID_Validation_Status__c='Invalid'];
   list<Account>saveList = new list<Account>();
   
   if(AccList.size()>0)
   {
   for(Account Acc:AccList)
   {
     if(Acc.Tax_ID_Validation_Status__c=='Invalid')
     {
      Acc.InvalidVATReminder__c=true;
      saveList.add(Acc);
     }
   }
   if(saveList.size()>0)
   {
   try{
     update saveList ;
     }
      catch(Exception e)
     {
      e.getmessage();
     }
   }
  }
 }
  global void finish(Database.batchableContext info)
    {     
    } 
    
    global void execute(SchedulableContext sc) 
    {
      InvalidVATReminderBatch runbatch = new InvalidVATReminderBatch ();  
       ID batchprocessid = Database.executeBatch(runbatch);   
    }
  }

 I have only 20 records that meets this criteria (Invalid status), when I ran the batch it seems to be executing recursively and the same 20 emails are sent out recursively. But the same batch seems to be working well in sandbox, it was executed only once ( received all 20 emails only once). Do you have any idea why the batch was getting executed recursively in Prod?
Here's my batch schedule:
System.schedule('VAT reminder', '0 0 13 4 * ? *', new InvalidVATReminderBatch());

Any help/ ideas would be appreciated.
Thanks

I have a batch class which invokes a webservice to validate a VAT ID field. It works well in sandbox, but in Production there are more than 1000+ records which is pulled by this batch (meeting the criteria) and the call does'nt seem to be successful. I see this error in debug log-System.CalloutException: Exceeded maximum time allotted for callout (120000 ms)

I'd given the batch size as 200 but no idea on how to limit the call out time. Also, I am new to web services.
Can somebody give me an idea on how to get over this issue.

Many Thanks in advance!

Sree

We have an Account manager field under Account (lookup to user) and whenever an account manager is added/ updated, should add the same user to the Account Team object granting full access to Account/Opportunity/Contact (via Account share).

I have written the method to call on insert and update of Account, where I am inserting account team member & share record.On update, it removes the old user from Account Team and adds the new one. It works well for some users (profiles), but sometimes tend to throw exception-
first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

By default the share record takes OWD as default level access (which in my case is Account- Public read Only, all others Private)

Could you please suggest me how I can get over this exception and grant full access via share record. In short, the Account Manager (ie Account Team) should have full access to the three objects.

Many Thanks in advance!
Hello,

I am trying to convert a javascript button to a lightning controller.  I have the basis of the controller, but how do I add the 'if this oppty type, then select this document' and the 'require these parts' sections in the lightning controller?

Javascript:
//********* Option Declarations (Do not modify )*********// 

var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='1';var CEM='';var CES='';var STB='';var SSB='';var SES='';var SEM='';var SRS='';var SCS ='';var RES=''; 

//********* Page Callout (Do not modify) *********// 
if("{!Opportunity.Authorized_Signer__c}" == false) 

alert('Must select an Authorized Signer to send to'); 


else{ 

//KIA 4-6-18 Must have Authorized Signer Email Address 
if("{!Opportunity.Authorized_Email__c}" == false) 

alert('Oops! You are trying to send to a contact with no email address. Go to the Contact Record, add an email address and then resend the DocuSign.'); 


else{ 

//KSJ 3-1-17 Must have agreement terms// 

if("{!Opportunity.Agreement_Term__c}" == ''|| "{!Opportunity.Agreement_Term__c}" == null ) 

alert('Agreement Term cannot be blank'); 

else{ 


//KSJ 3-1-17 Must have auto renewal terms// 

if("{!Opportunity.Auto_Renewal_Term__c}" == ''|| "{! Opportunity.Auto_Renewal_Term__c}" == null) 

alert('Auto Renewal Term must be filled in'); 

else{ 


//KSJ 3-1-17 Container type cannot be blank// 

if("{! Opportunity.Oppty_Type__c }" == "UCO Service" && {!(ISBLANK( Opportunity.Outdoor_Container_Type__c ))}) 

alert('Must have an Outdoor Container Type' ); 

else{ 


//KSJ 3-1-17 For Trap must have #of trap agreement// 

if("{! Opportunity.Oppty_Type__c }" == "Trap Service" && {!(ISBLANK( Opportunity.No_traps_agreement__c ))}) 

alert('# Traps - Agreement cannot be blank' ); 

else{ 

//KSJ 3-1-17 Indoor container cannot be blank// 

if("{! Opportunity.Oppty_Type__c }" == "UCO Service & Indoor Equipment" && "{! Opportunity.Indoor_Container_Type__c}" == '' || "{!Opportunity.Indoor_Container_Type__c}" == null ) 

alert('# Indoor Container Type cannot be Blank' ); 

else{ 


//KSJ 3-1-17 Must have a quote number// 

if("{! Opportunity.Oppty_Type__c }" == "UCO Service & Indoor Equipment" && {!(ISBLANK( Opportunity.Quote_No__c ))}) 

alert('Quote No cannot be blank' ); 

else{ 









//CES='TEST'; 
CES='Documents for your Review and Signature'; 
DST='{!Opportunity.Template_DST__c}'; 
//DST='XXXXXXXX'; 
//alert(DST); 

//4-17-17 RAM commented out Alert CRL 
// Custom Recipient List (Individual) 
CRL='Email~{!Opportunity.Authorized_Email__c};LastName~{!Opportunity.Authorized_Signer__c};Role~Authorized Signer;RoutingOrder~1,Email~{!Opportunity.OwnerEmail};FirstName~{!Opportunity.OwnerFirstName};LastName~{!Opportunity.OwnerLastName};Role~Opportunity Owner;RoutingOrder~2,Email~{!Opportunity.Office_Mgr_Email__c};LastName~{!URLENCODE(JSENCODE(Opportunity.Facility__c))};Role~Carbon Copy;RoutingOrder~3'; 
//alert(CRL); 


// Custom Contact Role Map (default config role) 
CCRM = 'Authorized Signer~Authorized Signer;Opportunity Owner~Opportunity Owner;Carbon Copy~Carbon Copy'; 

// Custom Contact Type Map (default Signer) 
CCTM = 'Authorized Signer~Signer;Opportunity Owner~Signer;Carbon Copy~Carbon Copy'; 

OCO='Send'; 


//********* Page Callout (Do not modify) *********// 

window.location.href = 
"/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.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= "+RES; 







}

Controller:
global class DocusignRedirect {
	private static final STRING PARAM_DSEID = 'DSEID';
    private static final STRING PARAM_SOURCE_ID = 'SourceID';
    private static final STRING PARAM_SOURCE_CRL = 'CRL';
    
    private Opportunity anOpportunity = null;
    
    public DocusignRedirect(ApexPages.StandardController stdController)
    {
        Id opportunityId = stdController.getRecord().Id;
        this.anOpportunity = DAL_Opportunity.getById(opportunityId);
    }
    
    public PageReference autoRun()
    {
        if (this.anOpportunity == null)
        {
            return null;
        }
        PageReference pageRef = Page.dsfs__Docusign_CreateEnvelope;
        pageRef.getParameters().put(PARAM_DSEID, '0');
        pageRef.getParameters().put(PARAM_SOURCE_ID, this.anOpportunity.Id);
        pageRef.getParameters().put(PARAM_CRL, this.getCRL());
        pageRef.setRedirect(true);
        return pageRef;
        
    }
    
    private String getCRL()
    {
        return 'Email~' + anOpportunity.Authorized_Email__c +
            ';Name~' + anOpportunity.Authorized_Signer__c +
            ';RoutingOrder~1;';
    }
}

 
Hi there,

I have a batch class that checks if a field "Tax ID validation status" is invalid and sends reminder to the Account Owners. My batch basically checks a checkbox and I have a  Worflow rule to trigger email alert when this checkbox is true:

global class InvalidVATReminderBatch implements Database.batchable<sObject>,Schedulable{
 public String query;
    global Database.QueryLocator start(Database.BatchableContext bc){
        return database.getQuerylocator('Select id,Tax_ID_Validation_Status__c,recordtypeId from Account');
    } 
    
   global void execute(Database.batchableContext info, List<Account> accnt){ 
   list<Account>AccList = [Select id,InvalidVATReminder__c,Tax_ID_Validation_Status__c,recordtypeId,recordtype.name from Account where Tax_ID_Validation_Status__c='Invalid'];
   list<Account>saveList = new list<Account>();
   
   if(AccList.size()>0)
   {
   for(Account Acc:AccList)
   {
     if(Acc.Tax_ID_Validation_Status__c=='Invalid')
     {
      Acc.InvalidVATReminder__c=true;
      saveList.add(Acc);
     }
   }
   if(saveList.size()>0)
   {
   try{
     update saveList ;
     }
      catch(Exception e)
     {
      e.getmessage();
     }
   }
  }
 }
  global void finish(Database.batchableContext info)
    {     
    } 
    
    global void execute(SchedulableContext sc) 
    {
      InvalidVATReminderBatch runbatch = new InvalidVATReminderBatch ();  
       ID batchprocessid = Database.executeBatch(runbatch);   
    }
  }

 I have only 20 records that meets this criteria (Invalid status), when I ran the batch it seems to be executing recursively and the same 20 emails are sent out recursively. But the same batch seems to be working well in sandbox, it was executed only once ( received all 20 emails only once). Do you have any idea why the batch was getting executed recursively in Prod?
Here's my batch schedule:
System.schedule('VAT reminder', '0 0 13 4 * ? *', new InvalidVATReminderBatch());

Any help/ ideas would be appreciated.
Thanks

I have a batch class which invokes a webservice to validate a VAT ID field. It works well in sandbox, but in Production there are more than 1000+ records which is pulled by this batch (meeting the criteria) and the call does'nt seem to be successful. I see this error in debug log-System.CalloutException: Exceeded maximum time allotted for callout (120000 ms)

I'd given the batch size as 200 but no idea on how to limit the call out time. Also, I am new to web services.
Can somebody give me an idea on how to get over this issue.

Many Thanks in advance!

Sree

Hi,

 

When i make a call to an external web service from an apex class, i got the following error:

 

System.CalloutException: IO Exception: Read timed out 

 

The call works fine with the test environnement where the web service is exposed. However wiht their production environment, the error above is thrown. Is it a problem of mass data or security (proxy) ?

 

Could you help please ?

 

All the best,

 

Anzar.