• shambavi
  • NEWBIE
  • 40 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 5
    Replies
public with sharing class APTS_UOMConversionTriggerHandler implements ITriggerHandler {
  public static Boolean isTriggerDisabled = true;
  public class ApplicationException extends Exception {}
  
  public Boolean isDisabled(){
     try{
         Boolean disabled=false;
         if (TriggerSettings__c.getInstance().UOMConversionTrigger__c) {
           disabled=false;
         } 
         else {
           disabled=isTriggerDisabled;
         }
       return disabled;
     }catch(Exception e) {throw new ApplicationException(e);}
    }
  
    public void beforeInsert(List<SObject> newUOMConversionList){
      /
    } 
 
    public void beforeUpdate(List<SObject> newUOMConversionList, Map<Id, SObject> newUOMConversionMap, List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){
      
    }
    
    public void beforeDelete(List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){
      
    }
 
    public void afterInsert(List<SObject> newUOMConversionList, Map<Id, SObject> newUOMConversionMap){
      //Logic to check if the product is active and it is newly inserted.If so will trigger digital pricing
      try{
        onAfterInsertUOMConversion((List<APTS_UOM_Conversion__c>)newUOMConversionList);  
      }catch(DmlException e) {throw new ApplicationException(e);}

    }
  
    public void afterUpdate(List<SObject> newUOMConversionList , Map<Id, SObject> newUOMConversionMap, List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){
       //Logic to check if the product's isactive field has changed.If so will trigger digital pricing
      try{
        onAfterUpdateUOMConversion((Map<Id, APTS_UOM_Conversion__c>)newUOMConversionMap,(Map<Id, APTS_UOM_Conversion__c>)oldUOMConversionMap);
      }catch(DmlException e) {throw new ApplicationException(e);}
    }
    
    public void afterDelete(List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){
     
    }
  
    public void afterUndelete(List<SObject> newUOMConversionList, Map<Id, SObject> newUOMConversionMap){
      
    }
    
     public static void onAfterInsertUOMConversion(List<APTS_UOM_Conversion__c> newUOMConversionList){
        try{
         Set<Id> uOMConversionIdsToBeSentToSAPPO=  new Set<Id>();
           for(APTS_UOM_Conversion__c prodTrans:newUOMConversionList){
               if(prodTrans.APTS_Product_Active__c){
                  uOMConversionIdsToBeSentToSAPPO.add(prodTrans.APTS_Product__c);   
               }    
           }
           
           if(!uOMConversionIdsToBeSentToSAPPO.isEmpty()){
             APTS_IntegrationLogHandlerUtility.createIntegrationLogs(uOMConversionIdsToBeSentToSAPPO);      
           }
         }catch(Exception e) {throw new ApplicationException(e);}
     }
   
    public static void onAfterUpdateUOMConversion(Map<Id, APTS_UOM_Conversion__c> newUOMConversionMap,Map<Id, APTS_UOM_Conversion__c> oldUOMConversionMap){
        try{
    Set<Id> uOMConversionIdsToBeSentToSAPPO=new Set<Id>();
        List<Schema.FieldSetMember> relatedFieldSet=new List<Schema.FieldSetMember>();
        relatedFieldSet=APTS_IntegrationLogHandlerUtility.readFieldSet('APTS_UOMFieldsForDigitalProdIntegration','APTS_UOM_Conversion__c');    
        //List<Product2> productsToBeSentToSAPPO=  new List<Product2>();
           for(Id prodId:newUOMConversionMap.keySet()){
               if(newUOMConversionMap.get(prodId).APTS_Product_Active__c && 
                   APTS_IntegrationLogHandlerUtility.checkIfValidToSend(newUOMConversionMap.get(prodId),oldUOMConversionMap.get(prodId),relatedFieldSet)){
                      uOMConversionIdsToBeSentToSAPPO.add(newUOMConversionMap.get(prodId).APTS_Product__c);   
               }    
           }
           
           if(!uOMConversionIdsToBeSentToSAPPO.isEmpty()){
             APTS_IntegrationLogHandlerUtility.checkAndCreateIntegrationLogs(uOMConversionIdsToBeSentToSAPPO);      
           }
        }catch(Exception e) {throw new ApplicationException(e);}
     }
}
Thanks
 
Hi Guys,
 i have one agreement objcet , in this object some records will be there, in these records i want to select one primary record...
please help on this.. below is my code ..
<apex:page standardController="Apttus__APTS_Agreement__c" extensions="OnLoadController">
<apex:form >

        <apex:outputText value="{!Apttus__APTS_Agreement__c.Name}" rendered="false"/>
        <apex:outputText value="{!Apttus__APTS_Agreement__c.Apttus__Account__c}" rendered="false"/>
      
        <apex:outputText value="{!Apttus__APTS_Agreement__c.APTS_Primary__c}" rendered="false"/>

 <apex:commandButton id="btnOnLoad" action="{!onLoad}" value="On Load" style="display: none" />
        
        <script>
            var btnOnLoad = document.getElementById("{!$Component.btnOnLoad}");
        </script>
        
        <apex:pageBlock mode="edit" rendered="{!hasErrors}" >
            <apex:pageMessages />
            <apex:pageBlockButtons location="bottom" >
                    <apex:commandButton action="{!doMakePrimary}" value="Make Primary"/>  
                <apex:commandButton action="{!doCancel}" value="{!$Label.apttus__apts_agreement__cancel}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
    
    <script>
        // register to invoke the function after the page load
        var hasErrors = "{!hasErrors}";
        if (hasErrors.toLowerCase() == 'false') {
            window.onload = function() { 
                // on load
                btnOnLoad.click();
            };
        }
    </script>
    
</apex:page>

and Controller code...
 
public class OnLoadController {

    public Apttus__APTS_Agreement__c agreement { get; set; }

    public OnLoadController(ApexPages.StandardController stdController){
        this.agreement = (Apttus__APTS_Agreement__c)stdController.getRecord();
    }
    
    public void doMakePrimary(){
        Apttus__APTS_Agreement__c agreementRec = [SELECT ID, APTS_Primary__c, Apttus__Related_Opportunity__c FROM Apttus__APTS_Agreement__c WHERE ID =: agreement.Id];
        //add If condition to check other agreement records
        agreementRec.APTS_Primary__c = TRUE;
        insert agreementRec;
    }
    
    public PageReference doCancel() {
        PageReference agreementPage = new PageReference('/' + agreement.id);
        return agreementPage;
    }
    
    public String hasErrors { get; set; }

    public PageReference onLoad() {
             update agreement;
        return null;
    }


}

Thanks In Advance... 
<apex:page standardController="Apttus__APTS_Agreement__c" 
           extensions="APTS_Agreement.AgreementMakePrimaryController" >
    
    <apex:form >
    
        <!--  required fields -->
        <apex:outputText value="{!Apttus__APTS_Agreement__c.Name}" rendered="false"/>
        <apex:outputText value="{!Apttus__APTS_Agreement__c.APTS_Primary__c}" rendered="false"/>
        
        <!--  hidden action buttons -->
        <apex:commandButton id="btnOnLoad" action="{!onLoad}" value="On Load" style="display: none" />
        
        <script>
            var btnOnLoad = document.getElementById("{!$Component.btnOnLoad}");
        </script>
        
        <apex:pageBlock mode="edit" rendered="{!hasErrors}" >
            <apex:pageMessages />
            <apex:pageBlockButtons location="bottom" >
                <apex:commandButton action="{!doCancel}" value="{!$Label.aApttus__APTS_Agreement__cancel}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
    
    <script>
        // register to invoke the function after the page load
        var hasErrors = "{!hasErrors}";
        if (hasErrors.toLowerCase() == 'false') {
            window.onload = function() { 
                // on load
                btnOnLoad.click();
            };
        }
    </script>
    
</apex:page>
please write controller for vf page...

Thanks in Advance 
please 
We will use status category and statuses to sync of the agreement and describe conceptually to which opportunity stage this should be linked back. To auto sync the agreement with opportunity either a process builder or trigger is required.
global class PartnerUserNotLoggedfor30DaysBatch implements Database.Batchable<sObject>{
    
    Date myDate;
    
    Date myDate30Days;
    Id email30DaysTemplateId;
    
    global PartnerUserNotLoggedfor30DaysBatch(){
        myDate = Date.today();
        myDate30Days= Date.today()+30;
        
    }
   
    global Database.querylocator start(Database.BatchableContext BC)
    {
        return Database.getQueryLocator([SELECT Id,name,IsActive,isFrozen__c,IsPortalEnabled,Validity_Date__c,ABB_Manager__c,
                            Profile.name,LastLoginDate,email FROM User WHERE IsPortalEnabled = true AND IsActive = true 
                            AND isFrozen__c = false AND (Profile.Name=:Label.SYS_ABBExtChannelPartnerCommunityUser 
                            OR Profile.Name=:Label.SYS_ABB_Ext_Rep_Community_User 
                            OR Profile.Name=:Label.SYS_ABB_Ext_Agent_Community_User)
                            AND LastLoginDate =: myDate30Days]);   
    }
    global void execute(Database.BatchableContext BC, List<User> listOfUsers)
    { 
    
        Set<Id> setChnlMngrIds=new Set<Id>();
        Set<Id> set30DaysExpUsers = new set<Id>();
        Set<Id> set4WksExpUsers = new set<Id>();
        Map<Id,User> mapOf30DaysExpUsers = new Map<Id,User>();
        Map<Id,User> mapOf4WksExpUsers = new Map<Id,User>();
        Map<Id,User> mapOfABBMngrEmails;
        
        if(listOfUsers.size()>0 && listOfUsers != null){
            
            for(user usr : listOfUsers){
                setChnlMngrIds.add(usr.ABB_Manager__c);
                if(usr.LastLoginDate == myDate30Days){
                    set30DaysExpUsers.add(usr.id);
                    mapOf30DaysExpUsers.put(usr.id,usr);
                }
            }
            if(setChnlMngrIds.size()>0){
            mapOfABBMngrEmails = new Map<Id,User>([Select id,name,email from User where id =: setChnlMngrIds Limit 5000 ]);
            }
            
            List<String> lstToAddRecp = new List<String>();
            List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
            
            if(mapOf30DaysExpUsers != null && mapOf30DaysExpUsers.size()>0){
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                for(User usr : mapOf30DaysExpUsers.values()){
                    String BodyText = '<html><body>Dear '+ usr.name +'<br/><br/>'+
                                        'Not Logged for 30 days '+ usr.LastLoginDate+'.'+
                                        '<br/><br/>'+
                                        'To extend your access for next 365 days please contact your ABB Channel Manager.'+
                                        '<br/><br/>Best regards,<br/>SFDC Team<br/><br/>'+
                                        'This is system notification. Please do not reply to this email.'+
                                        '</body></html>'; 
                                        email.setHtmlBody(BodyText );
                    lstToAddRecp.add(usr.email);
                    email.setToAddresses(lstToAddRecp);
                    
                    email.setTargetObjectId(usr.id);
                    email.setSaveAsActivity(false);
                    emails.add(email);    
                    lstToAddRecp.clear();
                }
            }
            
            
            if(emails != null){                    
                Messaging.SendEmailResult[] results = Messaging.sendEmail(emails);
                
            }
            
        }
        
        
    }
    
    global void finish(Database.BatchableContext BC)
      {

      }
}

Thnaks in Advance..
public with sharing class AccountListWrapper {
   
   public with sharing class DisplayAccountRecords {
        
        @AuraEnabled public Id AccountId { get; set; }
        @AuraEnabled public Account AccountRecord { get; set; }
        @AuraEnabled public Boolean IsSelected { get; set; }
        @AuraEnabled public String AccountConfig { get; set; }
        @AuraEnabled public String strGUID {get;set;}
        
        public DisplayAccountRecords(){
               IsSelected = false;
        }
        
    }
}

Thanks in Advance... 
global class CreatedAccounts
{
  @InvocableMethod
  global static void CreatedAccount(List<ClsCheckMDM> checkList)
  {
    Id uId = userinfo.getUserId();
    List<Account> updateList = new List<Account> ();
    User partnerCreatedUser = [SELECT Id FROM User WHERE Name = 'Partner Created Account' LIMIT 1];
    User userRec = [SELECT Id, ABB_Manager__c from user where id = :uId LIMIT 1];
    List<Id> accountIds = new List<Id> ();

    for (ClsCheckMDM check : checkList)
    {
      accountIds.add(check.accountId);
    }

    Map<Id, Account> accountMap = new Map<Id, Account> ([SELECT Id, OwnerId FROM Account WHERE Id IN :accountIds LIMIT 100]);
    Map<Id, List<Account_team__c>> accountTeamMap = new Map<Id, List<Account_team__c>> ();

    for(Account_team__c accountTeam : [SELECT Id, Account__c, Account_Access__c, User__c FROM Account_team__c WHERE Account__c IN :accountMap.keySet()])
    {
      if(accountTeamMap.containsKey(accountTeam.Account__c))
      {
        accountTeamMap.get(accountTeam.Account__c).add(accountTeam);
      }
      else
      {
        accountTeamMap.put(accountTeam.Account__c, new List<Account_team__c> { accountTeam });
      }
    }

    List<AccountShare> accountShareRecord = new List<AccountShare> ();
    for (ClsCheckMDM check : checkList)
    {

      if (accountMap.containsKey(check.accountId))
      {
        Account acc = accountMap.get(check.accountId);
        if (!check.isMDM)
        {

          if (accountTeamMap.containsKey(acc.Id))
          {
            for (Account_team__c accountTeam : accountTeamMap.get(acc.Id))
            {
              accountShareRecord.add(new AccountShare
              (
               AccountId = accountTeam.Account__c,
               UserOrGroupId = accountTeam.User__c,
               AccountAccessLevel = (accountTeam.Account_Access__c == 'Read/Write') ? 'Edit' : 'Read',
               OpportunityAccessLevel = 'Read',
               RowCause = 'Manual'
              ));

            }
          }

          acc.OwnerId = partnerCreatedUser.Id;

        }
        else
        {
          acc.OwnerId = userRec.ABB_Manager__c;
        }
        updateList.add(acc);
      }
    }
    try
    {
      update updateList;
      if (!accountShareRecord.isEmpty())
      {
        insert accountShareRecord;
      }
    }
    catch(Exception ex)
    {
      System.debug(logginglevel.ERROR, ex.getMessage());
    }
  }

  global class ClsCheckMDM
  {
    @InvocableVariable
    global Id accountId;

    @InvocableVariable
    global Boolean isMDM;
  }

}

 
public class BitSet {
 public Map < String, Integer > alphaNumCharCodes {
  get;
  set;
 }
 public Map < String, Integer > base64CharCodes {
  get;
  set;
 }
 
 public BitSet() {
  LoadCharCodes();
 }

 public void LoadCharCodes() {
  alphaNumCharCodes = new Map < String, Integer > {
   'A' => 65,
   'B' => 66,
   'C' => 67,
   'D' => 68,
   'E' => 69,
   'F' => 70,
   'G' => 71,
   'H' => 72,
   'I' => 73,
   'J' => 74,
   'K' => 75,
   'L' => 76,
   'M' => 77,
   'N' => 78,
   'O' => 79,
   'P' => 80,
   'Q' => 81,
   'R' => 82,
   'S' => 83,
   'T' => 84,
   'U' => 85,
   'V' => 86,
   'W' => 87,
   'X' => 88,
   'Y' => 89,
   'Z' => 90
  };
  base64CharCodes = new Map < String, Integer > ();
 
  Set < String > pUpperCase = alphaNumCharCodes.keySet();
  for (String pKey: pUpperCase) {
 
   alphaNumCharCodes.put(pKey.toLowerCase(), alphaNumCharCodes.get(pKey) + 32);
 
   base64CharCodes.put(pKey, alphaNumCharCodes.get(pKey) - 65);
   base64CharCodes.put(pKey.toLowerCase(), alphaNumCharCodes.get(pKey) - (65) + 26);
  }
 
  for (Integer i = 0; i <= 9; i++) {
   alphaNumCharCodes.put(string.valueOf(i), i + 48);
  
   base64CharCodes.put(string.valueOf(i), i + 52);
  }
    /
    AlphaNumCharCodes.put('+', 43);
    AlphaNumCharCodes.put('/', 47);
    Base64CharCodes.put('+', 62);
    Base64CharCodes.put('/', 63);
 }
 
 public List < Integer > testBits(String pValidFor, List < Integer > nList) {
  List<Integer> ret = new List<Integer>();
    Integer target = 0;
    
    for(Integer i=0; i < pValidFor.length();i++){
        Integer cur = (Base64CharCodes.get((pValidFor.Substring(i, i+1))));
       
        for (Integer j = 0; j < 6; j++) {
            if ((cur & 32) == 32) {
                for(Integer n : nList){
                    if(target == n){
                        ret.add(target);
                        break;
                    }
                }
            }
           
            cur <<= 1;
      
            target++;
        }
    }
    return ret;

 }
 public class PicklistEntryWrapper{
    
    public PicklistEntryWrapper(){}
    public String active {get;set;}
    public String defaultValue {get;set;}
    public String label {get;set;}
    public String value {get;set;}
    public String validFor {get;set;}
 }
}

Thanks in Advance...
Please create a Custom List View Button "New Case" that will pre-populate the Contact, Account, Email, based on the current logged in User if the User is external (community profile) and use the standard functionality if he is not
The contact field should be updated with $User.ContactID if the Record Type is Case from Communities


Thanks in Advance.......


Thanks & Regards
Gopal. 
public with sharing class APTS_UOMConversionTriggerHandler implements ITriggerHandler {
  public static Boolean isTriggerDisabled = true;
  public class ApplicationException extends Exception {}
  
  public Boolean isDisabled(){
     try{
         Boolean disabled=false;
         if (TriggerSettings__c.getInstance().UOMConversionTrigger__c) {
           disabled=false;
         } 
         else {
           disabled=isTriggerDisabled;
         }
       return disabled;
     }catch(Exception e) {throw new ApplicationException(e);}
    }
  
    public void beforeInsert(List<SObject> newUOMConversionList){
      /
    } 
 
    public void beforeUpdate(List<SObject> newUOMConversionList, Map<Id, SObject> newUOMConversionMap, List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){
      
    }
    
    public void beforeDelete(List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){
      
    }
 
    public void afterInsert(List<SObject> newUOMConversionList, Map<Id, SObject> newUOMConversionMap){
      //Logic to check if the product is active and it is newly inserted.If so will trigger digital pricing
      try{
        onAfterInsertUOMConversion((List<APTS_UOM_Conversion__c>)newUOMConversionList);  
      }catch(DmlException e) {throw new ApplicationException(e);}

    }
  
    public void afterUpdate(List<SObject> newUOMConversionList , Map<Id, SObject> newUOMConversionMap, List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){
       //Logic to check if the product's isactive field has changed.If so will trigger digital pricing
      try{
        onAfterUpdateUOMConversion((Map<Id, APTS_UOM_Conversion__c>)newUOMConversionMap,(Map<Id, APTS_UOM_Conversion__c>)oldUOMConversionMap);
      }catch(DmlException e) {throw new ApplicationException(e);}
    }
    
    public void afterDelete(List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){
     
    }
  
    public void afterUndelete(List<SObject> newUOMConversionList, Map<Id, SObject> newUOMConversionMap){
      
    }
    
     public static void onAfterInsertUOMConversion(List<APTS_UOM_Conversion__c> newUOMConversionList){
        try{
         Set<Id> uOMConversionIdsToBeSentToSAPPO=  new Set<Id>();
           for(APTS_UOM_Conversion__c prodTrans:newUOMConversionList){
               if(prodTrans.APTS_Product_Active__c){
                  uOMConversionIdsToBeSentToSAPPO.add(prodTrans.APTS_Product__c);   
               }    
           }
           
           if(!uOMConversionIdsToBeSentToSAPPO.isEmpty()){
             APTS_IntegrationLogHandlerUtility.createIntegrationLogs(uOMConversionIdsToBeSentToSAPPO);      
           }
         }catch(Exception e) {throw new ApplicationException(e);}
     }
   
    public static void onAfterUpdateUOMConversion(Map<Id, APTS_UOM_Conversion__c> newUOMConversionMap,Map<Id, APTS_UOM_Conversion__c> oldUOMConversionMap){
        try{
    Set<Id> uOMConversionIdsToBeSentToSAPPO=new Set<Id>();
        List<Schema.FieldSetMember> relatedFieldSet=new List<Schema.FieldSetMember>();
        relatedFieldSet=APTS_IntegrationLogHandlerUtility.readFieldSet('APTS_UOMFieldsForDigitalProdIntegration','APTS_UOM_Conversion__c');    
        //List<Product2> productsToBeSentToSAPPO=  new List<Product2>();
           for(Id prodId:newUOMConversionMap.keySet()){
               if(newUOMConversionMap.get(prodId).APTS_Product_Active__c && 
                   APTS_IntegrationLogHandlerUtility.checkIfValidToSend(newUOMConversionMap.get(prodId),oldUOMConversionMap.get(prodId),relatedFieldSet)){
                      uOMConversionIdsToBeSentToSAPPO.add(newUOMConversionMap.get(prodId).APTS_Product__c);   
               }    
           }
           
           if(!uOMConversionIdsToBeSentToSAPPO.isEmpty()){
             APTS_IntegrationLogHandlerUtility.checkAndCreateIntegrationLogs(uOMConversionIdsToBeSentToSAPPO);      
           }
        }catch(Exception e) {throw new ApplicationException(e);}
     }
}
Thanks
 
Hi Guys,
 i have one agreement objcet , in this object some records will be there, in these records i want to select one primary record...
please help on this.. below is my code ..
<apex:page standardController="Apttus__APTS_Agreement__c" extensions="OnLoadController">
<apex:form >

        <apex:outputText value="{!Apttus__APTS_Agreement__c.Name}" rendered="false"/>
        <apex:outputText value="{!Apttus__APTS_Agreement__c.Apttus__Account__c}" rendered="false"/>
      
        <apex:outputText value="{!Apttus__APTS_Agreement__c.APTS_Primary__c}" rendered="false"/>

 <apex:commandButton id="btnOnLoad" action="{!onLoad}" value="On Load" style="display: none" />
        
        <script>
            var btnOnLoad = document.getElementById("{!$Component.btnOnLoad}");
        </script>
        
        <apex:pageBlock mode="edit" rendered="{!hasErrors}" >
            <apex:pageMessages />
            <apex:pageBlockButtons location="bottom" >
                    <apex:commandButton action="{!doMakePrimary}" value="Make Primary"/>  
                <apex:commandButton action="{!doCancel}" value="{!$Label.apttus__apts_agreement__cancel}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
    
    <script>
        // register to invoke the function after the page load
        var hasErrors = "{!hasErrors}";
        if (hasErrors.toLowerCase() == 'false') {
            window.onload = function() { 
                // on load
                btnOnLoad.click();
            };
        }
    </script>
    
</apex:page>

and Controller code...
 
public class OnLoadController {

    public Apttus__APTS_Agreement__c agreement { get; set; }

    public OnLoadController(ApexPages.StandardController stdController){
        this.agreement = (Apttus__APTS_Agreement__c)stdController.getRecord();
    }
    
    public void doMakePrimary(){
        Apttus__APTS_Agreement__c agreementRec = [SELECT ID, APTS_Primary__c, Apttus__Related_Opportunity__c FROM Apttus__APTS_Agreement__c WHERE ID =: agreement.Id];
        //add If condition to check other agreement records
        agreementRec.APTS_Primary__c = TRUE;
        insert agreementRec;
    }
    
    public PageReference doCancel() {
        PageReference agreementPage = new PageReference('/' + agreement.id);
        return agreementPage;
    }
    
    public String hasErrors { get; set; }

    public PageReference onLoad() {
             update agreement;
        return null;
    }


}

Thanks In Advance... 
<apex:page standardController="Apttus__APTS_Agreement__c" 
           extensions="APTS_Agreement.AgreementMakePrimaryController" >
    
    <apex:form >
    
        <!--  required fields -->
        <apex:outputText value="{!Apttus__APTS_Agreement__c.Name}" rendered="false"/>
        <apex:outputText value="{!Apttus__APTS_Agreement__c.APTS_Primary__c}" rendered="false"/>
        
        <!--  hidden action buttons -->
        <apex:commandButton id="btnOnLoad" action="{!onLoad}" value="On Load" style="display: none" />
        
        <script>
            var btnOnLoad = document.getElementById("{!$Component.btnOnLoad}");
        </script>
        
        <apex:pageBlock mode="edit" rendered="{!hasErrors}" >
            <apex:pageMessages />
            <apex:pageBlockButtons location="bottom" >
                <apex:commandButton action="{!doCancel}" value="{!$Label.aApttus__APTS_Agreement__cancel}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
    
    <script>
        // register to invoke the function after the page load
        var hasErrors = "{!hasErrors}";
        if (hasErrors.toLowerCase() == 'false') {
            window.onload = function() { 
                // on load
                btnOnLoad.click();
            };
        }
    </script>
    
</apex:page>
please write controller for vf page...

Thanks in Advance 
please 
global class CreatedAccounts
{
  @InvocableMethod
  global static void CreatedAccount(List<ClsCheckMDM> checkList)
  {
    Id uId = userinfo.getUserId();
    List<Account> updateList = new List<Account> ();
    User partnerCreatedUser = [SELECT Id FROM User WHERE Name = 'Partner Created Account' LIMIT 1];
    User userRec = [SELECT Id, ABB_Manager__c from user where id = :uId LIMIT 1];
    List<Id> accountIds = new List<Id> ();

    for (ClsCheckMDM check : checkList)
    {
      accountIds.add(check.accountId);
    }

    Map<Id, Account> accountMap = new Map<Id, Account> ([SELECT Id, OwnerId FROM Account WHERE Id IN :accountIds LIMIT 100]);
    Map<Id, List<Account_team__c>> accountTeamMap = new Map<Id, List<Account_team__c>> ();

    for(Account_team__c accountTeam : [SELECT Id, Account__c, Account_Access__c, User__c FROM Account_team__c WHERE Account__c IN :accountMap.keySet()])
    {
      if(accountTeamMap.containsKey(accountTeam.Account__c))
      {
        accountTeamMap.get(accountTeam.Account__c).add(accountTeam);
      }
      else
      {
        accountTeamMap.put(accountTeam.Account__c, new List<Account_team__c> { accountTeam });
      }
    }

    List<AccountShare> accountShareRecord = new List<AccountShare> ();
    for (ClsCheckMDM check : checkList)
    {

      if (accountMap.containsKey(check.accountId))
      {
        Account acc = accountMap.get(check.accountId);
        if (!check.isMDM)
        {

          if (accountTeamMap.containsKey(acc.Id))
          {
            for (Account_team__c accountTeam : accountTeamMap.get(acc.Id))
            {
              accountShareRecord.add(new AccountShare
              (
               AccountId = accountTeam.Account__c,
               UserOrGroupId = accountTeam.User__c,
               AccountAccessLevel = (accountTeam.Account_Access__c == 'Read/Write') ? 'Edit' : 'Read',
               OpportunityAccessLevel = 'Read',
               RowCause = 'Manual'
              ));

            }
          }

          acc.OwnerId = partnerCreatedUser.Id;

        }
        else
        {
          acc.OwnerId = userRec.ABB_Manager__c;
        }
        updateList.add(acc);
      }
    }
    try
    {
      update updateList;
      if (!accountShareRecord.isEmpty())
      {
        insert accountShareRecord;
      }
    }
    catch(Exception ex)
    {
      System.debug(logginglevel.ERROR, ex.getMessage());
    }
  }

  global class ClsCheckMDM
  {
    @InvocableVariable
    global Id accountId;

    @InvocableVariable
    global Boolean isMDM;
  }

}

 
Please create a Custom List View Button "New Case" that will pre-populate the Contact, Account, Email, based on the current logged in User if the User is external (community profile) and use the standard functionality if he is not
The contact field should be updated with $User.ContactID if the Record Type is Case from Communities


Thanks in Advance.......


Thanks & Regards
Gopal.