• Krystal D. Carter
  • NEWBIE
  • 25 Points
  • Member since 2015


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
Hi I'm getting the same the  following error on my test class: "Argument must be an object that implements Database.Batchable"
I've used this code multiple times before in regards to an Apex Sharing Rule.  But in this org it's throwing an error.  I've bolded the line that's throwing the error. Any help would be appreciated. 



@istest
public class  testAgreementsharecalc
{
     Public static testMethod void testingagreementsharecalc()
     {
        Test.startTest();
        agreementsharecalc sb = new agreementsharecalc();
        Apttus__APTS_Agreement__c objAgreement = new Apttus__APTS_Agreement__c();
        objAgreement.Apttus__Requestor__c = UserInfo.getUserId();
        insert objAgreement;
        
        ID batchprocessid = Database.executeBatch(sb);          
        Test.stopTest();
     }
}
I have a need to autopopulate a custom task field called "Signer" which would come from my custom "Agreement" object related to my task.  I'd need the logic to look something like this: 

If Task's "Related To ID" starts with "a0Z" (which denotes the custom Agreement object) 

THEN populate Task's Signer__c with the Related Agreement's Signer's name. (Signer on the Agreement is a lookup field, so I want the Name (String) from the record selected in the lookup ie: Agreement.Signer__r.Name__c (something like that.

lease help! Thanks, community!
Hi,  

I need help.  I have successfully written a trigger (my first) which adds users in 3 fields as editors of a custom object record. Where I need help is if one or more of those users in those 3 fields change, I need the previous user to no longer have access to the record. 

For Example: 
VP Approver is John Smith -- Record is Saved -- John Smith is given RW access to the record --> VP Approve is changed to Mary Morton--> John Smith no longer has any access to the record and Mary Morton now has RW to the record. 

Here is my current code which is working fine to give VP Approver access, but it does not take the access away when the user is changed. Any help is much appreciated! 

trigger agreement_Sharing on Apttus__APTS_Agreement__c (after update) {

    // We only execute the trigger after a Agreement record has been inserted 
    // because we need the Id of the Agreement record to already exist.
    if(trigger.isUpdate){
        
     
    List<Apttus__APTS_Agreement__Share> sharesToDelete = [SELECT Id 
                                                FROM Apttus__APTS_Agreement__Share 
                                                WHERE ParentId IN :trigger.newMap.keyset() 
                                                AND RowCause = 'Requester Sharing'];
//if(!sharesToDelete.isEmpty()){
    //Database.Delete(sharesToDelete, false);
//} 
    // APTS_Agreement__Share is the "Share" table that was created when the
    // Organization Wide Default sharing setting was set to "Private".
    // Allocate storage for a list of APTS_Agreement__Share records.
    List<Apttus__APTS_Agreement__Share> agreementShares  = new List<Apttus__APTS_Agreement__Share>();
        
        

    // For each of the Agreement records being inserted, do the following:
    for(Apttus__APTS_Agreement__c agreement : trigger.new){

        // Create a new APTS_Agreement__Share record to be inserted in to the APTS_Agreement__Share table.
        Apttus__APTS_Agreement__Share agreementShare = new Apttus__APTS_Agreement__Share();
            
        // Populate the APTS_Agreement__Share record with the ID of the record to be shared.
        agreementShare.ParentId = agreement.Id;
            
        // Then, set the ID of user or group being granted access. In this case,
        // we’re setting the Id of the agreement that was specified by 
        // the User in the agreement__c lookup field on the Agreement record.  
        // (See Image 1 to review the Agreement object's schema.)
        agreementShare.UserOrGroupId = agreement.GP_APVL_C_Level__c;
        //agreementShare.UserOrGroupId = agreement.GP_APVL_Sr_Director__c;
        //agreementShare.UserOrGroupId = agreement.GP_APVL_VP__c;
        //agreementShare.UserOrGroupId = agreement.GP_APVL_Additional__c;
       
        
        // Specify that the agreement should have edit access for 
        // this particular Agreement record.
        agreementShare.AccessLevel = 'edit';
            
        // Specify that the reason the agreement can edit the record is 
        // because he’s the agreement.
        // (agreement_Sharing__c is the Apex Sharing Reason that we defined earlier.)
        agreementShare.RowCause = Schema.Apttus__APTS_Agreement__Share.RowCause.Requester_Sharing__c;
            
        // Add the new Share record to the list of new Share records.
        agreementShares.add(agreementShare);
    }
        
    for(Apttus__APTS_Agreement__c agreement : trigger.new){

        Apttus__APTS_Agreement__Share agreementShare = new Apttus__APTS_Agreement__Share();
        agreementShare.ParentId = agreement.Id;
        agreementShare.UserOrGroupId = agreement.GP_APVL_Sr_Director__c;
        agreementShare.AccessLevel = 'edit';
        agreementShare.RowCause = Schema.Apttus__APTS_Agreement__Share.RowCause.Requester_Sharing__c;
        agreementShares.add(agreementShare);
    }
        
    for(Apttus__APTS_Agreement__c agreement : trigger.new){

        Apttus__APTS_Agreement__Share agreementShare = new Apttus__APTS_Agreement__Share();
        agreementShare.ParentId = agreement.Id;
        agreementShare.UserOrGroupId = agreement.GP_APVL_VP__c;
        agreementShare.AccessLevel = 'edit';
        agreementShare.RowCause = Schema.Apttus__APTS_Agreement__Share.RowCause.Requester_Sharing__c;
        agreementShares.add(agreementShare);
    } 
        
    for(Apttus__APTS_Agreement__c agreement : trigger.new){

        Apttus__APTS_Agreement__Share agreementShare = new Apttus__APTS_Agreement__Share();
        agreementShare.ParentId = agreement.Id;
        agreementShare.UserOrGroupId = agreement.GP_APVL_Additional__c;
        agreementShare.AccessLevel = 'edit';
        agreementShare.RowCause = Schema.Apttus__APTS_Agreement__Share.RowCause.Requester_Sharing__c;
        agreementShares.add(agreementShare);
    }
    // Insert all of the newly created Share records and capture save result 
    Database.SaveResult[] agreementShareInsertResult = Database.insert(agreementShares,false);
        
    // Error handling code omitted for readability.
    }
}
Hi I'm getting the same the  following error on my test class: "Argument must be an object that implements Database.Batchable"
I've used this code multiple times before in regards to an Apex Sharing Rule.  But in this org it's throwing an error.  I've bolded the line that's throwing the error. Any help would be appreciated. 



@istest
public class  testAgreementsharecalc
{
     Public static testMethod void testingagreementsharecalc()
     {
        Test.startTest();
        agreementsharecalc sb = new agreementsharecalc();
        Apttus__APTS_Agreement__c objAgreement = new Apttus__APTS_Agreement__c();
        objAgreement.Apttus__Requestor__c = UserInfo.getUserId();
        insert objAgreement;
        
        ID batchprocessid = Database.executeBatch(sb);          
        Test.stopTest();
     }
}
global class UserLogJob implements Schedulable {

       global void execute(SchedulableContext SC) {

          EmailUserLogController M = new EmailUserLogController();
          m.UserLog();

       }

    }
  • February 17, 2016
  • Like
  • 0
I have a need to autopopulate a custom task field called "Signer" which would come from my custom "Agreement" object related to my task.  I'd need the logic to look something like this: 

If Task's "Related To ID" starts with "a0Z" (which denotes the custom Agreement object) 

THEN populate Task's Signer__c with the Related Agreement's Signer's name. (Signer on the Agreement is a lookup field, so I want the Name (String) from the record selected in the lookup ie: Agreement.Signer__r.Name__c (something like that.

lease help! Thanks, community!
Hi,  

I need help.  I have successfully written a trigger (my first) which adds users in 3 fields as editors of a custom object record. Where I need help is if one or more of those users in those 3 fields change, I need the previous user to no longer have access to the record. 

For Example: 
VP Approver is John Smith -- Record is Saved -- John Smith is given RW access to the record --> VP Approve is changed to Mary Morton--> John Smith no longer has any access to the record and Mary Morton now has RW to the record. 

Here is my current code which is working fine to give VP Approver access, but it does not take the access away when the user is changed. Any help is much appreciated! 

trigger agreement_Sharing on Apttus__APTS_Agreement__c (after update) {

    // We only execute the trigger after a Agreement record has been inserted 
    // because we need the Id of the Agreement record to already exist.
    if(trigger.isUpdate){
        
     
    List<Apttus__APTS_Agreement__Share> sharesToDelete = [SELECT Id 
                                                FROM Apttus__APTS_Agreement__Share 
                                                WHERE ParentId IN :trigger.newMap.keyset() 
                                                AND RowCause = 'Requester Sharing'];
//if(!sharesToDelete.isEmpty()){
    //Database.Delete(sharesToDelete, false);
//} 
    // APTS_Agreement__Share is the "Share" table that was created when the
    // Organization Wide Default sharing setting was set to "Private".
    // Allocate storage for a list of APTS_Agreement__Share records.
    List<Apttus__APTS_Agreement__Share> agreementShares  = new List<Apttus__APTS_Agreement__Share>();
        
        

    // For each of the Agreement records being inserted, do the following:
    for(Apttus__APTS_Agreement__c agreement : trigger.new){

        // Create a new APTS_Agreement__Share record to be inserted in to the APTS_Agreement__Share table.
        Apttus__APTS_Agreement__Share agreementShare = new Apttus__APTS_Agreement__Share();
            
        // Populate the APTS_Agreement__Share record with the ID of the record to be shared.
        agreementShare.ParentId = agreement.Id;
            
        // Then, set the ID of user or group being granted access. In this case,
        // we’re setting the Id of the agreement that was specified by 
        // the User in the agreement__c lookup field on the Agreement record.  
        // (See Image 1 to review the Agreement object's schema.)
        agreementShare.UserOrGroupId = agreement.GP_APVL_C_Level__c;
        //agreementShare.UserOrGroupId = agreement.GP_APVL_Sr_Director__c;
        //agreementShare.UserOrGroupId = agreement.GP_APVL_VP__c;
        //agreementShare.UserOrGroupId = agreement.GP_APVL_Additional__c;
       
        
        // Specify that the agreement should have edit access for 
        // this particular Agreement record.
        agreementShare.AccessLevel = 'edit';
            
        // Specify that the reason the agreement can edit the record is 
        // because he’s the agreement.
        // (agreement_Sharing__c is the Apex Sharing Reason that we defined earlier.)
        agreementShare.RowCause = Schema.Apttus__APTS_Agreement__Share.RowCause.Requester_Sharing__c;
            
        // Add the new Share record to the list of new Share records.
        agreementShares.add(agreementShare);
    }
        
    for(Apttus__APTS_Agreement__c agreement : trigger.new){

        Apttus__APTS_Agreement__Share agreementShare = new Apttus__APTS_Agreement__Share();
        agreementShare.ParentId = agreement.Id;
        agreementShare.UserOrGroupId = agreement.GP_APVL_Sr_Director__c;
        agreementShare.AccessLevel = 'edit';
        agreementShare.RowCause = Schema.Apttus__APTS_Agreement__Share.RowCause.Requester_Sharing__c;
        agreementShares.add(agreementShare);
    }
        
    for(Apttus__APTS_Agreement__c agreement : trigger.new){

        Apttus__APTS_Agreement__Share agreementShare = new Apttus__APTS_Agreement__Share();
        agreementShare.ParentId = agreement.Id;
        agreementShare.UserOrGroupId = agreement.GP_APVL_VP__c;
        agreementShare.AccessLevel = 'edit';
        agreementShare.RowCause = Schema.Apttus__APTS_Agreement__Share.RowCause.Requester_Sharing__c;
        agreementShares.add(agreementShare);
    } 
        
    for(Apttus__APTS_Agreement__c agreement : trigger.new){

        Apttus__APTS_Agreement__Share agreementShare = new Apttus__APTS_Agreement__Share();
        agreementShare.ParentId = agreement.Id;
        agreementShare.UserOrGroupId = agreement.GP_APVL_Additional__c;
        agreementShare.AccessLevel = 'edit';
        agreementShare.RowCause = Schema.Apttus__APTS_Agreement__Share.RowCause.Requester_Sharing__c;
        agreementShares.add(agreementShare);
    }
    // Insert all of the newly created Share records and capture save result 
    Database.SaveResult[] agreementShareInsertResult = Database.insert(agreementShares,false);
        
    // Error handling code omitted for readability.
    }
}
In my org i have enabled Person Account, and i have a visualforce page where i need to get Salutation,FirstName and LastName field from person account, But when i call it using <apex:inputField value="{!account.lastname}"/> I'm getting only field label here i'm using "account" as a standard controller.

But I have used same line of code i.e <apex:inputField value="{!account.lastname}"/> to get contact's Lastname using "Contact" as standard controller

Here in the below code I'm getting only field label for "Salutation" and "Lastname" but I'm getting both label and field for "Account Name"

can anyone tell me what's problem here ?


<apex:page standardController="Account" extensions="pick_list" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >

   <apex:pageBlockSectionItem >
         <apex:outputlabel value="First Name"/>
         <apex:outputpanel >
         <apex:inputfield value="{!account.Salutation}" />
         &nbsp;
         <apex:inputfield value="{!account.FirstName}" />
         </apex:outputpanel>
  </apex:pageBlockSectionItem>
  <apex:inputfield value="{!account.lastname}"
  <apex:inputfield value="{!account.name}"
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>  
</apex:page>