• VRK
  • NEWBIE
  • 155 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 72
    Questions
  • 63
    Replies
HI 
Email Tab under Activity is Missing in Sandbox, its available in Production.
I tried in add in Edit Lighting Record pages, But i can't .
This issue appears recently....
Any one idea how to fix this ?

User-added image
  • January 20, 2021
  • Like
  • 0

Hi
When upload attachements for Case Documnet Object getting View State Error .
Below scenario , getting View State Error:
Business tryng to upload PDF Documents more than 2 mb, getting this View State Error. 

When try to upload small size files more than 30+ also not getting this Error .
But, in our code we didn't mention anywhere File Size , pls let me know if required any modifications on below code :
VF Page :
---------

<apex:page docType="html-5.0" standardController="Case" extensions="CaseDocumentFileUploadCX" title="Upload Case document">
    <apex:includeScript value="{!URLFOR($Resource.jquery)}"  />
    <apex:form id="uploadForm">

    <script>
        var $jQuery = jQuery.noConflict();

        $jQuery(document).ready(function(){
            var $uploadNameInput = $jQuery('[id$="uploadFileName"]');
            //$uploadNameInput.prop('readonly', true);

            $jQuery('[id$="fileUploadInput"]').on('change', function(){
                var $this = $jQuery(this);
                $jQuery('[id$="documentLabel"]').val($this.val().split(/(\\|\/)/g).pop());
                //$uploadNameInput.prop('readonly', false);
                $uploadNameInput.val($this.val().split(/(\\|\/)/g).pop());
                //$uploadNameInput.prop('readonly', true);
                //refreshPage();
            });
            
            
        });
        
        </script>
        <script type="text/javascript">
        var caseDocId;
        var caseId = '{!caseId}';
        function evaluateCaseDoc() {
            $jQuery('#okuploadbtn').hide();
            $jQuery('#msg').text('Uploading');


            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.CaseDocumentFileUploadCX.evaluate}',
                '{!jsonString}',
                '{!uploadFileName}',
                function(result1, event){
                    caseDocId = result1;
                    Visualforce.remoting.Manager.invokeAction(
                        '{!$RemoteAction.CaseDocumentFileUploadCX.executeRequest}',
                        result1,
                        function(result2, event){
                            $jQuery('#msg').text(result2);
                            if(result2 === 'Document Upload SUCCESSFUL!'){
                                $jQuery('#donebtn').show();
                            }else{
                                $jQuery('#retrybtn').show();
                            }
                        }, 
                        {escape: true}
                    );
            }, 
                {escape: true}
            );
        }
        
        </script>
        <!--<apex:actionFunction name="createCaseDoc" action="{!evaluate}" />-->
        <apex:actionFunction name="reupload" action="{!reupload}" />
        <apex:actionFunction name="loadCaseDoc" action="{!loadCaseDoc}" />
        <apex:outputPanel id="showstate"/>
        <apex:pageBlock id="filePageBlock" >
            <apex:pageMessages />
            <apex:pageBlockSection columns="1" title="File selection" id="fileSelection" >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.CaseDocument__c.Fields.FilePath__c.Label}" />
                    <apex:inputFile value="{!fileUpload.body}" filename="{!fileUpload.name}" id="fileUploadInput" fileSize="{!caseDoc.FileSize__c}" contentType="{!caseDoc.MimeType__c}" style="width:100%;height:20px;" />
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock id="fileSelectionDetails" >
            <apex:pageBlockSection columns="1" title="File upload details">
                <apex:inputField value="{!caseDoc.Name}" label="{!$ObjectType.CaseDocument__c.Fields.Name.Label}" id="documentLabel" required="true" style="width:50%;" />
                <apex:inputText value="{!uploadFileName}" label="File name" id="uploadFileName" style="width:50%;" />
                <apex:inputField value="{!caseDoc.MimeType__c}"  rendered="false" label="{!$ObjectType.CaseDocument__c.Fields.MimeType__c.Label}" style="width:50%;"  />
                <apex:inputField value="{!caseDoc.BusinessCode__c}" style="width:50%;" />
                <apex:inputField value="{!caseDoc.CaseId__c}" label="{!$ObjectType.CaseDocument__c.Fields.CaseId__c.Label}" id="fileUploadCase" style="width:50%;"  />
            </apex:pageBlockSection>
            
            <apex:commandButton action="{!showCheckOpen}" value="Upload" />
        </apex:pageBlock>
        
        <apex:outputPanel id="showFileOpenPopUp">
          <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!showFileOpenPopUp}"/>
            <apex:outputPanel styleClass="custPopup overlayDialog cssDialog inlineEditDialog" style="display:block; visibility:visible;" layout="block" rendered="{!showFileOpenPopUp}">
              <div class="topRight">
                <div class="topLeft">
                  <h2></h2>
                </div>
              </div>
              <br />
              <apex:outputPanel id="msgLabelClass" rendered="{!showFileOpenPopUp}">
                  <div id="msg">{!$Label.CheckFileOpenDialogMessage}</div>
                  <br />
                  <br />
              </apex:outputPanel>                         
              <div class="buttons zen" style="margin-left: 100px; ">
                 <input id = "okuploadbtn" class="btn" width="20px" type="button" value="{!$Label.CheckFileOpenDialogOkButton}" onclick="evaluateCaseDoc();return false; "  />
                 <input id = "donebtn" style="display:none;" class="btn" width="20px" type="button" value="{!$Label.CheckFileOpenDialogOkButton}" onclick="window.open('/'+caseDocId,'_self');"  />
                <input id = "retrybtn" style="display:none;" class="btn" width="20px" type="button" value="{!$Label.CheckFileOpenDialogOkButton}" onclick="window.open('/apex/CaseDocumentFileUpload?id='+caseId,'_self');"  />
                </div>
            </apex:outputPanel>
        </apex:outputPanel>
                
    </apex:form>

    <style>

      [id$='msgLabelClass'] {
         display: inline;        
      }

      [id$='msgLabelClass'] > label {
         margin-left: 10px;
        block-width: 260px;
         display: inline-block;
      }

      [id$='msgLabelClass'] + table {
         margin-left: 10px;
         display: inline;
         vertical-align: middle;
         width: auto;
      }

      .custPopup{
         background-color: white;
         z-index: 100;
         left: 50%;
         position: absolute;
         /* These are the 3 css properties you will need to change so the popup 
            displays in the center of the screen. First set the width. Then set 
            margin-left to negative half of what the width is. You can add 
            the height property for a fixed size pop up if you want.*/
         width: 300px;
         height: 130px;
         margin-left: -250px;
         top:100px;
         padding-bottom: 15px;
      }

      .custPopup h2 {
                margin-right: 30px;
      }
      
      .popupBackground{
                background-color:black;
                opacity: 0.20;
                filter: alpha(opacity = 20);
                position: absolute;
                width: 100%;
                height: 100%;
                top: 0;
                left: 0;
                z-index: 99;
      }
    </style>    
</apex:page>

Apex class:
----------------
/**
 * @description Extension controller class for Case Document file upload functionality

 */
global with sharing class CaseDocumentFileUploadCX {
    public Document fileUpload {get;set;}
    public String uploadFileName {get;set;}
    public CaseDocument__c caseDoc {get;set;}
    public Case currentCase {get;set;}
    public Integer fileSize {get;set;}
    public String jsonString {get;set;}
    //19.JAN.2015 Yogesh Gupta, NYLIM  Added new Dialog
    public Boolean showFileOpenPopUp{get;set;}
    public String caseDocId {get;set;}
    public String caseId {get;set;}
    private boolean isSuccess;

    private static String injectHeader = ' DMS Document Maintenance (From Case Document)'; 
    private static String injectTempHeader = ' DMS Document Maintenance Temp (From Case Document)';
    private static Set<String> injectStates = new Set<String>{'5.4.a'};
    private static Set<String> injectTempStates = new Set<String>{'4.2.a','4.1.a','5.4.b'};
    

    global CaseDocumentFileUploadCX(ApexPages.StandardController controller) {
        currentCase = (Case) controller.getRecord();
        caseId  = currentCase.Id;
        fileUpload = new Document();
        uploadFileName = '';
        fileSize = 0;
        caseDoc = new CaseDocument__c();
        caseDoc.CaseId__c = currentCase.Id;
        caseDoc.MimeType__c = '';
        isSuccess = false;
    }

     @RemoteAction
    global static String evaluate(String jsonString, String uploadFileName ){
        PageReference newPage = null;
            
        System.debug('uploadFileName ::: ' + uploadFileName);
        String caseDocId;
         CaseDocument__c caseDoc = (CaseDocument__c) JSON.deserialize(jsonString, CaseDocument__c.class);
        //hideFileOpenPopUpPanel();
        if (uploadFileName != null && uploadFileName != '') {
            // Fetch file upload settings for the current user's profile
            FileUploadSettings__c fileUploadSettings = FileUploadSettings__c.getInstance(UserInfo.getProfileId());
            if (fileUploadSettings == null) {
                fileUploadSettings = FileUploadSettings__c.getOrgDefaults();
            }
            
            // Build the file path
            Id uid = UserInfo.getUserId();
            List<String> userFields = new List<String>{
                'Id',
                'FederationIdentifier'
            };
            String queryString = CS_UtilSObject.buildQuery(Schema.SObjectType.User, userFields);
            queryString += 'WHERE Id = :uid';
            User u = Database.query(queryString);
            //User u = [SELECT Id, FederationIdentifier FROM User WHERE Id = :uid];
            if (u != null) {
                caseDoc.FilePath__c = fileUploadSettings.get('NetworkFolderRootPath__c') + '\\' + u.FederationIdentifier + '\\' + uploadFileName;
            } else {
                ApexPages.Message errMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'User not found');
                ApexPages.addMessage(errMsg);
            }
            
            try {
                CaseDocumentTrigger_Handler.runAfterInsert = false;
                CaseDocumentTrigger_Handler.runAfterUpdate = false;
                
                insert caseDoc;
                caseDocId = caseDoc.Id;
                System.debug('* ** *** insert ' + caseDocId);
                
                
                newPage = New PageReference('/apex/CaseDocumentFileUpload2?id=' + caseDoc.id);
                newPage.setRedirect(true);
            } catch (Exception e) {
                //ApexPages.Message errMsg = new ApexPages.Message(ApexPages.Severity.FATAL, e.getMessage());
                //ApexPages.addMessage(errMsg);
                System.debug('Error ::: ' + e);
            }
        } else {
            ApexPages.Message errMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Please upload a document');
            ApexPages.addMessage(errMsg);
        }

        return caseDocId;
    }
    
    
    public PageReference showCheckOpen(){
        showFileOpenPopUp = true;
        jsonString = JSON.serialize(caseDoc);
        fileUpload = new Document();
        caseDoc = new CaseDocument__c();
        return null;
    }
    
    @RemoteAction
    global static String executeRequest(String caseDocId) {
            System.debug('* ** *** executeRequest');
            System.debug('* ** *** caseDocId ' + caseDocId);
            List<CaseDocument__c> caseDocList = [SELECT Id, IntegrationState__c, FilePath__c  FROM CaseDocument__c WHERE Id = :caseDocId LIMIT 1];
            if(caseDocList.isEmpty()){
                return 'UPLOAD FAILURE: An unexpected error has occured. Please try to upload document again. If you continue to experience difficulties, please contact your system administrator.';
            }
            
            CaseDocumentTrigger_Handler.runAfterInsert = false;
            CaseDocumentTrigger_Handler.runAfterUpdate = false;
            CaseDocumentTrigger_Handler.runBeforeUpdate = false;
                
            CaseDocument__c  caseDoc = caseDocList.get(0);
            if(injectStates.contains(caseDoc.IntegrationState__c)){
                if(!Test.isRunningTest()) CaseDocumentTrigger_Handler.executeRequests(new Set<String>{caseDoc.id},injectHeader,true); 
            }else{
                if(!Test.isRunningTest()) CaseDocumentTrigger_Handler.executeRequests(new Set<String>{caseDoc.id},injectTempHeader,true); 
            }
            
            PageReference newPage;
            caseDoc = [SELECT Id, CaseId__c, DMSInject_Code__c, DMSInject_Status__c FROM CaseDocument__c WHERE Id = :caseDocId];
            
            if(caseDoc.DMSInject_Status__c  == 'SUCCESS'){
                boolean isSuccess  = true;
                
                return 'Document Upload SUCCESSFUL!';
            }else{
                delete caseDoc;
                if(caseDoc.DMSInject_Code__c == '01'){
                    return 'DOCUMENT NOT FOUND: Please ensure that the document that you are trying to upload is located in the proper location and try again.';
                }else{
                    return 'UPLOAD FAILURE: An unexpected error has occured. Please try to upload document again. If you continue to experience difficulties, please contact your system administrator.';
                }
                
               
            }
            return 'UPLOAD FAILURE: An unexpected error has occured. Please try to upload document again. If you continue to experience difficulties, please contact your system administrator.';
            //return  New PageReference('/apex/CaseDocumentFileUpload2?id=' + caseDoc.id);

    }
   
   public PageReference reupload(){
        PageReference  newPage  =  New PageReference('/apex/CaseDocumentFileUpload?id=' + caseId);
        newPage.setRedirect(true);
        return newPage;  
    }
    
    public PageReference loadCaseDoc(){
        PageReference  newPage  = New PageReference('/' + caseDocId);
        
        newPage.setRedirect(true);
        return newPage;  
    }
    
    public PageReference showFileOpenPopUpPanel(){
        showFileOpenPopUp=True;
        return null;
    }

    public PageReference hideFileOpenPopUpPanel(){
        showFileOpenPopUp = False;
        return null;
    }   
}

Pls let me know any one have idea, how to fix View State error when upload large files for CaseDocumnet Object
Thanks
VRK

  • November 22, 2020
  • Like
  • 0
Hi pls l can et me know if anyone have idea on below points:

1. What is the difference between Salesforce IQ Inbox & salesforce Inbox?
ii. is it Licensed or Free ?

I need basic understandings, Pls don't share google stuff ....

Thannks
VRK
  • October 19, 2020
  • Like
  • 0
Hi 
let me know any Idea on below oncs:

1. Can we customize Standard Page Layouts without Using VF ?

Brief details :
I have Contact Object  and fiels like  firstName, lastName, phone,mobile,  Address1, Address2 ,Address 3.....
By using standard Page layout i created diffent sections like

Personal Information ( Section)
    firstName, lastName, phone
Contact details ( Section)
    Phone, landphone, mobile
Address ( Section)
    Address1, Address2 ,Address 3
    
Now the requirment is , My Business dont want Address as Section ...Instead of section , he wants to some thing different  Box Type or anyOther

I know ,By using Sections only we can divide Under Page Layouts.....
Do you have any idea, Without Using VF , can we go for Customize page layouts ?
************************************
2. Date format (EST) format issue When export data into CSV / Excel file?

Before export data , I updated Time Zone in below areas:
  1. Data loader 
  ii.User Time zone
  iii. System Time zone
 
 In Dataloader, When i query , Date format looks Correct
  2020-09-21 19:41:52
 But, when i export into CSV / Excel, the date format display as Below :
 2020-09-21T19:41:52.000Z

I tried, multiple ways , but its not working.
Any Idea on this?
  • October 08, 2020
  • Like
  • 0
Hi 
------------
Issue : Insufficinet access rights on cross-reference ID

Scenario : 
created process builder based on the Asset Object by follow critiria:

AND( AND( NOT ( ISPICKVAL([Asset].ADV_Classification__c,"") ), 
NOT ( ISPICKVAL([Asset].Accounting_Code__c,"") ), 
NOT ( ISPICKVAL([Asset].Accounting_Product__c,"") ), 
NOT ( ISPICKVAL([Asset].Executive_Summary__c,"") ), 
NOT ( ISPICKVAL([Asset].Accounting_Class__c,"") ) ,
ISPICKVAL( [Asset].Status, "onboarding") , 
OR( ISPICKVAL(PRIORVALUE([Asset].ADV_Classification__c) , ""), 
ISPICKVAL(PRIORVALUE([Asset].Accounting_Code__c) , ""), 
ISPICKVAL(PRIORVALUE([Asset].Accounting_Product__c) , ""), 
ISPICKVAL(PRIORVALUE([Asset].Executive_Summary__c) , ""), 
ISPICKVAL(PRIORVALUE([Asset].Accounting_Class__c) , "") ) ) )

Immediate actions:
Create a Record
RecordType : Task
Assigned To ID  : Assign Task Queue
Related to ID   : {Asset.Id}

This issue is getting for only few profiles, But admin profiles not getting 

I verified, profile have proper access for Task , Asset and required fields

And this is happening after Winter 21 Refresh .................

Do you have any ideas ?

Thanks
VRK
-----------------------
  • October 01, 2020
  • Like
  • 0
Hi guys,
I created Task Queue in Sandbox :
Queue Name  : testTask _Queue
Queue Email  : << valid busines user mail ID>>
Support Obj   :  Task
Queue members : << Valid business User mail ID>>
Send Email to Members  : checkbox is True.

After that i created one New Task and assign to this ' testTask _Queue'.
But, Queue member not received Task notifications.

I verified Email logs, mail Event status display As  Delivered.
----------
Date Time Internal Message ID Mail Event Recipient Sender Remote Host Bytes Transferred Salesforce.com User Message ID Header Retry Count Seconds In Queue Delivery Stage
########E1/AF-03942-3900B5F5  D abc@xxx.com noreply@chatter.salesforce.com206.210.19.232144050051I000002S5af<fUUah000000000000000000000000000000000000000000000QGH95F006hk6OrLuT9OPwGCztMvZCQ@sfdc.net>01.179895 

ii. setup -> Deliveribility --> All emails 
iii. Activity Settings ---> Already enable 'Enable User Control over Task Assignment Notifications'.

But , User informing  he didn't received any Task Notifications.

Pls let me know , can i miss anything or is there anything need to configure.
can you pls check and let me know your inputs on this

Thanks
VRK
  • September 13, 2020
  • Like
  • 0
Hi 
can anyone have  Winter 21 Release Features PPT, If yes can you pls share
Thanks
VRK
  • August 27, 2020
  • Like
  • 0
Hi Team
My scenario :
For Test purpose , we configured Lightning Sync in Sandbox for User ( tesUser)  . its working fine .
Now , we configured in Prod for the same user 'testUser'.
its also working fine.
Now the problem is , User can able to both Sandbox & Production calender events his Outlook

So, we removed user from Sandbox, Now in sandbox, stopped getting new calender Syns.
But the problem, Old calender syns are still displaying even if we remove 'testUser ' in lighting sync configuration related to Sandbox

can you pls let me know , how can we remove old user's calender Syncs related to Sandbox ?

Thanks
VRK
 
  • August 26, 2020
  • Like
  • 0
Hi Below code working for Before Insert But not for Before Update
anyone pls check whats the issue:

 try{
       Set<Id> Ids = new Set<Id>(); 
       Map<Id, Task> oldMapTask = (Map<Id, Task>)oldsoMap;
       Map<Id, Event> oldMapEvent = (Map<Id, Event>)oldsoMap;
        
        for(sobject sObj: newsoList){
               if(((Id)sObj.get('WhoId')).getSObjectType().getDescribe().getName() == 'Contact'){
                 if(activityType == 'Task'){
                    Task objTask = (Task)sObj;
                    if(oldsoMap == null){
                        objTask.Contact_Team_TPD__c = objTask.whoid;
                    }
                    else if(oldsoMap != null && objTask.whoid != oldMapTask.get(objTask.id).whoid){
                        objTask.Id = sObj.id;
                        objTask.Contact_Team_TPD__c = objTask.whoid;
                    }
                }
                 else if(activityType == 'Event'){
                     Event objEvent = (Event)sObj;
                     if(oldsoMap == null){
                        objEvent.Contact_Team_TPD__c = objEvent.whoid;
                    }
                    else if(oldsoMap != null && objEvent.whoid != oldMapTask.get(objEvent.id).whoid){
                        objEvent.Id = sObj.id;
                        objEvent.Contact_Team_TPD__c = objEvent.whoid;
                    }
                         
                    }                   
                }
                
            }

Thanks
VRK
  • August 25, 2020
  • Like
  • 0
Hi 
Scenario : when i create new Task / Event , then phone number field value populate from related to Contact Object Phone field.
For example :
I have Contact ' Test Contact ' and phone number is '99999999'.
When i create any Task /  Event, then Test Contact phone number is display as '99999999'.

Thanks
VRK
  • August 23, 2020
  • Like
  • 0

Hi I have few questions on Einstein activity capture , pls let me know if anyone have idea / Suggest for better solutions :

My requirement :
------------------------------

Calender Sync Salesforce ( bi-direction)
        &&
Task Sync ( bi-direction)

my analysis :
-------------
Lightning Sync :
---- After Dec 2020 , its depreciated and Salesforce suggested go for 'Einstein Actvity Capture'
My questions are ??
i. Is Einstein supports both Calender Sync & Tasks Sync
Note : I am sure, its support for Calender Sync But not sure for Tasks Sync

2. 
License = Sales Cloud Einstein --> Permission Set = Sales Cloud Einstein  
License = Inbox --> Permission Set = Inbox with Einstein Activity Capture
License = Sales Cloud --> Permission Set = Standard Einstein Activity Capture
Any one idea, which License supports for my requirement ? and is this License free or Cost ?

3. Do you have any other Suggestions for Tasks Sync ?
Pls treat this is little bit urget...
Thanks
VRK

  • August 04, 2020
  • Like
  • 0
Hi 
As per requrirement,  
Sync calender & Tasks with Salesforce 

i verify in google but not find not related
can you pls suggest if any one have /  free app exchane plugIns

Thanks
VRK
  • July 23, 2020
  • Like
  • 0
Hi 
Application_ c employerApplication = [ select id,Party__c,Plan_Type__c,State__c from Application__c ];


 public static EmpInfoWrapper caseInfoWrapperRecord(Application__c employerApplication,Id partyId){
        InfoWrapper wrapper = new InfoWrapper();
        wrapper.partyId = employerApplication.Party__c;
        wrapper.productType = ' Life';             
        if(employerApplication.Plan_Type__c == 'SI'){
            wrapper.product = ' Issue1';
        }else if (employerApplication.Plan_Type__c == 'GI'){
            wrapper.product = ' Issue2';
        }
        wrapper.stateId = employerApplication.State__c;
        return wrapper;
    }
    
    public class InfoWrapper{
        public String partyId{get;set;}  
        public String productType{get;set;} 
        public String product{get;set;}  
        public String stateId{get;set;}   
    } 
  • July 18, 2020
  • Like
  • 0
Hi 
i am having 2 issus, can u pls help on this :
1. How can i place below data Into Map :
(
        caseInfoWrapper:
        [carrierId=, 
        partyId=a1K2F000000lWJrUAM, 
        product=SI, 
        productType=Whole Life, 
        stateId=AK]
        )

2. When calling Wrapper class from one class to another class getting below error :
Illegal assignment from List<NewCtr.caseInfoWrapper> to List<String>

global class NewCtr {
public static List<caseInfoWrapper> caseInfoWrapperRecords(List<ATD_Application__c> applicationList,Id partyId){
      List<caseInfoWrapper> lsCaseWrappers = new List<caseInfoWrapper>();
        for(ATD_Application__c caseInfo : applicationList){
            caseInfoWrapper wrapper = new caseInfoWrapper();
            wrapper.partyId = caseInfo.Party__c;
            wrapper.productType = 'Whole Life';
            lsCaseWrappers.add(wrapper);
            system.debug('lsCaseWrappers***'+lsCaseWrappers);
        }
        return lsCaseWrappers;
    }
    
    }
    
global with sharing class NewHandler {

    list<caseInfoWrapper> wrapperRecords = NewCtr.caseInfoWrapperRecords(applicationList,partyId);
}
  • July 10, 2020
  • Like
  • 0
Hi all,
pls find my requirment below :

Required to  create http get from complex json  &   cast http response with apex.class of the json
if anyone have scenarios / code pls share

Thanks
VRK
 
  • July 09, 2020
  • Like
  • 0
Hi can anyone share code below requiremet :
{
  "Emp": {
    "Id": "a1K36000",
    "empName": {
      "value": "Life"
    },
    "empAge": {
      "value": " 40"
    },
    "Address": null,
  },
  "Manager": {
    "arrangementNumber": "S03434555",
    "payrollBenefit": {
      "value": "11"
    },
    "endOfEnrollment": "06/17/2020", 
    "isGIPolicyType": "YES",  
    "planType": {
      "value": " Issue"
    },
    "isSelect": "YES", 
    "totalNumber": 0 
  },
  
  My requirement is :
  In RestExplorer, Get Method, When i pass below URL # /services/apexrest/partyInquiry?recordId=a1K2F000000Wsom 
  I can get Results below Structure :
  
  EmpInfo
   --Id : a1K36000
     empName:Life
     empAge  : 40
     Address : null
 Manager 
    arrangementNumber: S03434555,
    payrollBenefit: : 11
    endOfEnrollment: "06/17/2020, 
    isGIPolicyType: "YES,  
    planType:  Issue
    isSelect: "YES", 
    totalNumber: 0 

Thanks
VRK
  • July 09, 2020
  • Like
  • 0

Hi
How to Fetch only '"Contract Release' in below JSON Data :::

data->
        [{"Date_Reviewed":"1989-05-06","Date_Sent":"1989-05-05","editable":true,"Form":"Contract Revision 1","Id":"a0S3F000001bXAIUA2"},
        {"Date_Reviewed":"2019-02-01","Date_Sent":"2019-02-01","editable":true,"Form":"Contract Revision 2","Id":"a0S3F000001bXAJUA2"},
        {"Date_Reviewed":"2020-12-27","editable":true,"Form":"Contract Revision 3","Id":"a0S3F000001bXAKUA2"},
        {"Date_Reviewed":"2020-01-03","Date_Sent":"2020-01-03","editable":true,"Form":"Contract Release","Id":"a0S3F000001bXALUA2"},
        {"Date_Reviewed":"2020-12-29","editable":true,"Form":"Contract Revision 4","Id":"a0S3F000001bXAMUA2"},
        {"Date_Reviewed":"2020-12-30","editable":true,"Form":"Contract Revision 5","Id":"a0S3F000001bXANUA2"},
]        

My code :
saveDataTable :function(component, event) {
var data = component.get("v.data"); 
 var editedRecords1 =  component.find("riderStatusDataTable").get("v.draftValues");
for (var x in data)
            {
              var d = data[x];
 if(d.Form == "Contract Release" ){
  TemporaryArray1.Date_Sent__c = editedRecords1[0].Date_Sent;
           TemporaryArray1.Date_Reviewed__c = editedRecords1[0].Date_Reviewed;
break;
}
But , this is not Restrict for Contract Release ........its applied for all the Forms . I need this is for only 'Contract Release'...
can anyone help me...
Thanks
VRK
  • June 26, 2020
  • Like
  • 0

Hi 
my requirment is :
i have cols  :picklist field( values:pick1,pick2,pick3) ,Date 1 & Date 2.
Form                                        Date1   
---------                                      ---------   
pick1       
pick2       
pick3  
my requirement is :
When date 1  update for pick1 .......... 
then, for pick2 date1 should display as  date1+30.
And        pick3 date1 should dispaly as date1+60.

Expected As:
Form                                        Date1   
---------                                      ---------   
pick1                                       1-june-2020
pick2                                       1-july -2020 ( expected)
pick3                                        1-Aug-2020( expected) .

my source code :
comp:
 <lightning:datatable
                                 aura:id="riderStatusDataTable"
                                 columns="{! v.columns }"
                                 data="{!v.data }"
                                 keyField="Id"
                                 onsave ="{!c.onSave}"
                                 hideCheckboxColumn="true"
                                 onrowaction="{! c.handleRowAction }" />

controller :

 component.set('v.columns', [
            {label: 'Form', fieldName: 'Form', type: 'string'},
            {label: 'Date', fieldName: 'Date_Sent', editable:"", type: 'date-local', sortable:true},
                   ]);

Any ideas how to acheive this :
Thanks
VRK

  • June 07, 2020
  • Like
  • 0
Hi i am performing picklist Update thorugh Metadata API...
it works for less data , But when we perform bulk data through Data
loader getting below error :
System.calloutException:IO Exception:ReadTimeout
i set Max 120 sec..But issue not solved for Bulk upload data.
Any ideas how to resolve
public class  MetadataApiCallout {
    //-------create new picklist value using metadata api call--------
    //-------use below method for bulk insert&Deactivate Values.    
    @future(callout = true)
    public static void createPicklistValue(String serializedObjectAPIMap, String serializedMap) {
        Map < String, Map < String, String >> ObjectFieldApiMap = (Map < String, Map < String, String >> ) JSON.deserialize(serializedObjectAPIMap, Map < String, Map < String, String >> .class);
        Map < String, Map < String, String >> picklistValueMap = (Map < String, Map < String, String >> ) JSON.deserialize(serializedMap, Map < String, Map < String, String >> .class); //----adding new values coming from compass helper.....        
        MetadataService.MetadataPort service = createService(); //-----Calling service method...        
        Map < String, String > schemaValueMap = new Map < String, String > ();
        //Collect recordtypes for each object in required format
        Map<String, List<String>> ObjectRtMap = new Map<String, List<String>>();
        List<String> rtValueList = new List<String>();
        for(RecordType rt : [SELECT Id, Name, developerName, SobjectType FROM RecordType WHERE SobjectType =:ObjectFieldApiMap.keySet()]){
            rtValueList.add(rt.SobjectType + '.' + rt.developerName);
            if(ObjectRtMap.containsKey(String.valueOf(rt.SobjectType).toUpperCase())){
                List<String> rtValues = new List<String>();
                rtValues = ObjectRtMap.get(String.valueOf(rt.SobjectType).toUpperCase());
                rtValues.add(String.valueOf(rt.SobjectType + '.' + rt.developerName).toUpperCase());
                ObjectRtMap.put(String.valueOf(rt.SobjectType).toUpperCase(), rtValues);
            }
            else{
                List<String> rtValues = new List<String>();
                rtValues.add(String.valueOf(rt.SobjectType + '.' + rt.developerName).toUpperCase());
                ObjectRtMap.put(String.valueOf(rt.SobjectType).toUpperCase(), rtValues); 
            }        
        }
        
        Map<String, List<MetadataService.PickListValue>> objFldMetaPickListValueMap = new Map<String, List<MetadataService.PickListValue>>();

        List<MetadataService.CustomField> customFieldListToUpdate = new List<MetadataService.CustomField>();        
        for (String objectApiName: ObjectFieldApiMap.keySet()) {            
            for (String fieldAPi: ObjectFieldApiMap.get(objectApiName).keySet()) {
                SobjectType objType = Schema.getGlobalDescribe().get(objectApiName);
                Map < String, Schema.SObjectField > objFields = objType.getDescribe().fields.getMap();
                SObjectField fieldName = objFields.get(fieldAPi);
                Schema.DescribeFieldResult fieldResult = fieldName.getDescribe();
                fieldResult = fieldResult.getSObjectField().getDescribe();
                List < Schema.PicklistEntry > ple = fieldResult.getPicklistValues();
                for (Schema.PicklistEntry pl: ple) {
                    if (pl.isActive()) {
                        schemaValueMap.put(pl.getValue(), pl.getLabel());
                    }
                }               
                MetadataService.CustomField customField = new MetadataService.CustomField();
                customField.fullName = objectApiName + '.' + fieldAPi;
                customField.label = ObjectFieldApiMap.get(objectApiName).get(fieldAPi);
                customField.type_x = 'Picklist';
                MetadataService.ValueSet picklistValueSet = new MetadataService.ValueSet();
                MetadataService.ValueSetValuesDefinition valueDefinition = new MetadataService.ValueSetValuesDefinition();
                List < MetadataService.CustomValue > values = new List < MetadataService.CustomValue > ();
                List<MetadataService.PickListValue>  fldPickListValueList =  new List<MetadataService.PickListValue>();
                //Add Existing values back in
                //condition for adding new values 
                //---for loop for adding new values from list-----------                
                for (String picklistValueInsert: picklistValueMap.get(fieldAPi).keySet()) {                    
                    MetadataService.CustomValue existingPLValue = new MetadataService.CustomValue();
                    existingPLValue.fullName = picklistValueInsert;
                    existingPLValue.default_x = false;
                    existingPLValue.label = picklistValueMap.get(fieldAPi).get(picklistValueInsert);
                    values.add(existingPLValue);

                    MetadataService.PickListValue fldPickListValue = new MetadataService.PickListValue();
                    fldPickListValue.fullName = picklistValueInsert;
                    fldPickListValue.default_x = false;
                    fldPickListValueList.add(fldPickListValue); 
                    System.debug(picklistValueInsert);
                }
                objFldMetaPickListValueMap.put(objectApiName+'.'+fieldAPi, fldPickListValueList);                    

                //------for loop for value deactivation.------------
                for (String picklistValue: schemaValueMap.keySet()) {
                    if (!picklistValueMap.get(fieldAPi).containsKey(picklistValue)) { //---condition check. not adding those existing value which is not coming from helper code. 
                        MetadataService.CustomValue existingPLValue = new MetadataService.CustomValue();
                        existingPLValue.fullName = picklistValue;
                        existingPLValue.isActive = False;
                        existingPLValue.default_x = false;
                        existingPLValue.label = schemaValueMap.get(picklistValue);
                        values.add(existingPLValue);
                    }
                }
                valueDefinition.value = values;
                valueDefinition.sorted = false;
                picklistValueSet.valueSetDefinition = valueDefinition;
                customField.valueSet = picklistValueSet;
                schemaValueMap.clear();
                
                  customFieldListToUpdate.add(customField);              
            }
        }
        //Update PicklistFields with new values        
        updateMetadata(service, splitMetadataIntoLists((MetadataService.Metadata[]) customFieldListToUpdate));
        
        List<List<String>> combinedRtValueList = new List<List<String>>();
        //Splitting into size of 10 to avoid limit
        combinedRtValueList = splitListIntoLists(rtValueList);
        List<MetadataService.RecordType> rtMetaList = new List<MetadataService.RecordType>();        
        for(Integer i=0; i<combinedRtValueList.size(); i++){
            if(!Test.isRunningTest())
                //read recordtype
                rtMetaList.addAll((List<MetadataService.RecordType>) service.readMetadata('RecordType', combinedRtValueList[i]).getRecords());            
        }
        Map<String, MetadataService.RecordType> rtMetaRTMap = new Map<String, MetadataService.RecordType>();        
        for(MetadataService.RecordType mRT : rtMetaList){            
            rtMetaRTMap.put(String.valueOf(mRT.fullName).toUpperCase(), mRT);            
        }
        List<MetadataService.RecordType> recordTypeListToUpdate = new List<MetadataService.RecordType>();
        for (String objectApiName: ObjectFieldApiMap.keySet()) {
            for(String rt : ObjectRtMap.get(objectApiName.toUpperCase())){
                MetadataService.RecordType recordType = new MetadataService.RecordType();
                recordType = rtMetaRTMap.get(rt);
                for (String fieldAPi: ObjectFieldApiMap.get(objectApiName).keySet()) { 
                   
                       // initialize the list of record type picklist values
                       MetadataService.RecordTypePicklistValue[] rtPickValues = new MetadataService.RecordTypePicklistValue[]{};
                       MetadataService.RecordTypePicklistValue rtPickValue = new MetadataService.RecordTypePicklistValue();
                       // Create the recordtypepicklist and add the list of picklist fields to the record type
                       rtPickValue.picklist = fieldAPi;
                       rtPickValue.values = objFldMetaPickListValueMap.get(objectApiName+'.'+fieldAPi);
                       System.debug(rtPickValue.values);
                       rtPickValues.add(rtPickValue);
                       if(!Test.isRunningTest())
                           recordType.picklistValues.addAll(rtPickValues);
                                            
                }              
                
        System.debug(recordType.picklistValues.size());
                recordTypeListToUpdate.add(recordType);
            } 
        }
        //Update RecordTypes             
        updateMetadata(service, splitMetadataIntoLists((MetadataService.Metadata[]) recordTypeListToUpdate));        
                         
    }
   
    //-----------create Metadata service----------------
    public static MetadataService.MetadataPort createService() {
        MetadataService.MetadataPort service = new MetadataService.MetadataPort();
        service.SessionHeader = new MetadataService.SessionHeader_element();
        service.SessionHeader.sessionId = UserInfo.getSessionId();
       // service.timeout_x = 40000;
        service.timeout_x = 120000;
        return service;
    }
    
    //readMetadata and updateMetdata has a limit of 10 elements per one callout
    //Spliting Metadata into lists of 10 elements to address above limit
    //-----------Split Master List into small lists of size 10 each----------------
    public static List<List<MetadataService.Metadata>> splitMetadataIntoLists(List<MetadataService.Metadata> listToSplit) {
        List<List<MetadataService.Metadata>> metadataListOfLists = new List<List<MetadataService.Metadata>>();        
        for(Integer i = 0 ; i < (listToSplit.size() / 10)+1 ; i++){
            List<MetadataService.Metadata> lstTemp = new List<MetadataService.Metadata>();
            for(Integer j=(i*10);(j<(i*10)+10) && j<listToSplit.size() ; j++){
                lstTemp.add(listToSplit.get(j));
            }
            metadataListOfLists.add(lstTemp);
        }        
        return metadataListOfLists;
    } 

    //-----------Split Master List into small lists of size 10 each----------------
    public static List<List<String>> splitListIntoLists(List<String> listToSplit) {
        List<List<String>> ListOfLists = new List<List<String>>();        
        for(Integer i = 0 ; i < (listToSplit.size() / 10)+1 ; i++){
            List<String> lstTemp = new List<String>();
            for(Integer j=(i*10);(j<(i*10)+10) && j<listToSplit.size() ; j++){
                lstTemp.add(listToSplit.get(j));
            }
            ListOfLists.add(lstTemp);
        }        
        return ListOfLists;
    }
    
    //-----------Update Metadata----------------
    public static void updateMetadata(MetadataService.MetadataPort service, List<List<MetadataService.Metadata>> metadataToUpdate) {
        for(Integer i=0; i<metadataToUpdate.size(); i++){
            if(!Test.isRunningTest()) {
                List<MetadataService.SaveResult> results = service.updateMetadata(metadataToUpdate[i]);  
                for(MetadataService.SaveResult r : results){
                    system.debug(r.errors);
                }
            }
        }
    }    
}
  • June 03, 2020
  • Like
  • 0
Hi Team,
i am getting issue in Time zone for below my requirement : could you pls help on this:
 if(!$A.util.isUndefinedOrNull(effectiveDate)){
                    effectiveDate.setMonth(11);
                    effectiveDate.setDate(31);
                }

 effectiveDate = new Date(effectiveDate);
                if(!$A.util.isUndefinedOrNull(effectiveDate)){
                effectiveDate.setFullYear(effectiveDate.getFullYear() + 1);
                effectiveDate.setDate(effectiveDate.getDate() - 1);
                }

When i try to execute code , i am getting some times Date as 
12/31/2020
or 
01/01/2021
But i need 12/31/2020.
I know its related to Time zone ....
Can you pls help anyone this .
Thanks
VRK
  • April 29, 2020
  • Like
  • 0
Hi folks,
How to send email alert / notificaiton from Case object to '''SLA Custom object ---> Peer reviwer ''' through APex class.
Can you some one pls provide code for this requirement 
Thanks
Sekhar
 
  • November 07, 2019
  • Like
  • 1
scenario :   Case is created in Salesforce,  Immediatly this case details be moved to third patry systems ( .net system, java sysstem,.......)
how can i do this ?
example : 
case # 12345 created in salesforce, immediatly case reflected in third party systems like java ,.net or some other systems.
Due to project cost, not going for opiton use third party integration tools like Dell boomi......or any other tools.

please provide any ideas on this requirement 
Thanks 
  • May 18, 2018
  • Like
  • 1
Hi pls l can et me know if anyone have idea on below points:

1. What is the difference between Salesforce IQ Inbox & salesforce Inbox?
ii. is it Licensed or Free ?

I need basic understandings, Pls don't share google stuff ....

Thannks
VRK
  • October 19, 2020
  • Like
  • 0
Hi 
------------
Issue : Insufficinet access rights on cross-reference ID

Scenario : 
created process builder based on the Asset Object by follow critiria:

AND( AND( NOT ( ISPICKVAL([Asset].ADV_Classification__c,"") ), 
NOT ( ISPICKVAL([Asset].Accounting_Code__c,"") ), 
NOT ( ISPICKVAL([Asset].Accounting_Product__c,"") ), 
NOT ( ISPICKVAL([Asset].Executive_Summary__c,"") ), 
NOT ( ISPICKVAL([Asset].Accounting_Class__c,"") ) ,
ISPICKVAL( [Asset].Status, "onboarding") , 
OR( ISPICKVAL(PRIORVALUE([Asset].ADV_Classification__c) , ""), 
ISPICKVAL(PRIORVALUE([Asset].Accounting_Code__c) , ""), 
ISPICKVAL(PRIORVALUE([Asset].Accounting_Product__c) , ""), 
ISPICKVAL(PRIORVALUE([Asset].Executive_Summary__c) , ""), 
ISPICKVAL(PRIORVALUE([Asset].Accounting_Class__c) , "") ) ) )

Immediate actions:
Create a Record
RecordType : Task
Assigned To ID  : Assign Task Queue
Related to ID   : {Asset.Id}

This issue is getting for only few profiles, But admin profiles not getting 

I verified, profile have proper access for Task , Asset and required fields

And this is happening after Winter 21 Refresh .................

Do you have any ideas ?

Thanks
VRK
-----------------------
  • October 01, 2020
  • Like
  • 0
Hi Team
My scenario :
For Test purpose , we configured Lightning Sync in Sandbox for User ( tesUser)  . its working fine .
Now , we configured in Prod for the same user 'testUser'.
its also working fine.
Now the problem is , User can able to both Sandbox & Production calender events his Outlook

So, we removed user from Sandbox, Now in sandbox, stopped getting new calender Syns.
But the problem, Old calender syns are still displaying even if we remove 'testUser ' in lighting sync configuration related to Sandbox

can you pls let me know , how can we remove old user's calender Syncs related to Sandbox ?

Thanks
VRK
 
  • August 26, 2020
  • Like
  • 0
Hi 
Scenario : when i create new Task / Event , then phone number field value populate from related to Contact Object Phone field.
For example :
I have Contact ' Test Contact ' and phone number is '99999999'.
When i create any Task /  Event, then Test Contact phone number is display as '99999999'.

Thanks
VRK
  • August 23, 2020
  • Like
  • 0

Hi I have few questions on Einstein activity capture , pls let me know if anyone have idea / Suggest for better solutions :

My requirement :
------------------------------

Calender Sync Salesforce ( bi-direction)
        &&
Task Sync ( bi-direction)

my analysis :
-------------
Lightning Sync :
---- After Dec 2020 , its depreciated and Salesforce suggested go for 'Einstein Actvity Capture'
My questions are ??
i. Is Einstein supports both Calender Sync & Tasks Sync
Note : I am sure, its support for Calender Sync But not sure for Tasks Sync

2. 
License = Sales Cloud Einstein --> Permission Set = Sales Cloud Einstein  
License = Inbox --> Permission Set = Inbox with Einstein Activity Capture
License = Sales Cloud --> Permission Set = Standard Einstein Activity Capture
Any one idea, which License supports for my requirement ? and is this License free or Cost ?

3. Do you have any other Suggestions for Tasks Sync ?
Pls treat this is little bit urget...
Thanks
VRK

  • August 04, 2020
  • Like
  • 0
Hi all,
pls find my requirment below :

Required to  create http get from complex json  &   cast http response with apex.class of the json
if anyone have scenarios / code pls share

Thanks
VRK
 
  • July 09, 2020
  • Like
  • 0

Hi
How to Fetch only '"Contract Release' in below JSON Data :::

data->
        [{"Date_Reviewed":"1989-05-06","Date_Sent":"1989-05-05","editable":true,"Form":"Contract Revision 1","Id":"a0S3F000001bXAIUA2"},
        {"Date_Reviewed":"2019-02-01","Date_Sent":"2019-02-01","editable":true,"Form":"Contract Revision 2","Id":"a0S3F000001bXAJUA2"},
        {"Date_Reviewed":"2020-12-27","editable":true,"Form":"Contract Revision 3","Id":"a0S3F000001bXAKUA2"},
        {"Date_Reviewed":"2020-01-03","Date_Sent":"2020-01-03","editable":true,"Form":"Contract Release","Id":"a0S3F000001bXALUA2"},
        {"Date_Reviewed":"2020-12-29","editable":true,"Form":"Contract Revision 4","Id":"a0S3F000001bXAMUA2"},
        {"Date_Reviewed":"2020-12-30","editable":true,"Form":"Contract Revision 5","Id":"a0S3F000001bXANUA2"},
]        

My code :
saveDataTable :function(component, event) {
var data = component.get("v.data"); 
 var editedRecords1 =  component.find("riderStatusDataTable").get("v.draftValues");
for (var x in data)
            {
              var d = data[x];
 if(d.Form == "Contract Release" ){
  TemporaryArray1.Date_Sent__c = editedRecords1[0].Date_Sent;
           TemporaryArray1.Date_Reviewed__c = editedRecords1[0].Date_Reviewed;
break;
}
But , this is not Restrict for Contract Release ........its applied for all the Forms . I need this is for only 'Contract Release'...
can anyone help me...
Thanks
VRK
  • June 26, 2020
  • Like
  • 0

Hi 
my requirment is :
i have cols  :picklist field( values:pick1,pick2,pick3) ,Date 1 & Date 2.
Form                                        Date1   
---------                                      ---------   
pick1       
pick2       
pick3  
my requirement is :
When date 1  update for pick1 .......... 
then, for pick2 date1 should display as  date1+30.
And        pick3 date1 should dispaly as date1+60.

Expected As:
Form                                        Date1   
---------                                      ---------   
pick1                                       1-june-2020
pick2                                       1-july -2020 ( expected)
pick3                                        1-Aug-2020( expected) .

my source code :
comp:
 <lightning:datatable
                                 aura:id="riderStatusDataTable"
                                 columns="{! v.columns }"
                                 data="{!v.data }"
                                 keyField="Id"
                                 onsave ="{!c.onSave}"
                                 hideCheckboxColumn="true"
                                 onrowaction="{! c.handleRowAction }" />

controller :

 component.set('v.columns', [
            {label: 'Form', fieldName: 'Form', type: 'string'},
            {label: 'Date', fieldName: 'Date_Sent', editable:"", type: 'date-local', sortable:true},
                   ]);

Any ideas how to acheive this :
Thanks
VRK

  • June 07, 2020
  • Like
  • 0
Hi i am performing picklist Update thorugh Metadata API...
it works for less data , But when we perform bulk data through Data
loader getting below error :
System.calloutException:IO Exception:ReadTimeout
i set Max 120 sec..But issue not solved for Bulk upload data.
Any ideas how to resolve
public class  MetadataApiCallout {
    //-------create new picklist value using metadata api call--------
    //-------use below method for bulk insert&Deactivate Values.    
    @future(callout = true)
    public static void createPicklistValue(String serializedObjectAPIMap, String serializedMap) {
        Map < String, Map < String, String >> ObjectFieldApiMap = (Map < String, Map < String, String >> ) JSON.deserialize(serializedObjectAPIMap, Map < String, Map < String, String >> .class);
        Map < String, Map < String, String >> picklistValueMap = (Map < String, Map < String, String >> ) JSON.deserialize(serializedMap, Map < String, Map < String, String >> .class); //----adding new values coming from compass helper.....        
        MetadataService.MetadataPort service = createService(); //-----Calling service method...        
        Map < String, String > schemaValueMap = new Map < String, String > ();
        //Collect recordtypes for each object in required format
        Map<String, List<String>> ObjectRtMap = new Map<String, List<String>>();
        List<String> rtValueList = new List<String>();
        for(RecordType rt : [SELECT Id, Name, developerName, SobjectType FROM RecordType WHERE SobjectType =:ObjectFieldApiMap.keySet()]){
            rtValueList.add(rt.SobjectType + '.' + rt.developerName);
            if(ObjectRtMap.containsKey(String.valueOf(rt.SobjectType).toUpperCase())){
                List<String> rtValues = new List<String>();
                rtValues = ObjectRtMap.get(String.valueOf(rt.SobjectType).toUpperCase());
                rtValues.add(String.valueOf(rt.SobjectType + '.' + rt.developerName).toUpperCase());
                ObjectRtMap.put(String.valueOf(rt.SobjectType).toUpperCase(), rtValues);
            }
            else{
                List<String> rtValues = new List<String>();
                rtValues.add(String.valueOf(rt.SobjectType + '.' + rt.developerName).toUpperCase());
                ObjectRtMap.put(String.valueOf(rt.SobjectType).toUpperCase(), rtValues); 
            }        
        }
        
        Map<String, List<MetadataService.PickListValue>> objFldMetaPickListValueMap = new Map<String, List<MetadataService.PickListValue>>();

        List<MetadataService.CustomField> customFieldListToUpdate = new List<MetadataService.CustomField>();        
        for (String objectApiName: ObjectFieldApiMap.keySet()) {            
            for (String fieldAPi: ObjectFieldApiMap.get(objectApiName).keySet()) {
                SobjectType objType = Schema.getGlobalDescribe().get(objectApiName);
                Map < String, Schema.SObjectField > objFields = objType.getDescribe().fields.getMap();
                SObjectField fieldName = objFields.get(fieldAPi);
                Schema.DescribeFieldResult fieldResult = fieldName.getDescribe();
                fieldResult = fieldResult.getSObjectField().getDescribe();
                List < Schema.PicklistEntry > ple = fieldResult.getPicklistValues();
                for (Schema.PicklistEntry pl: ple) {
                    if (pl.isActive()) {
                        schemaValueMap.put(pl.getValue(), pl.getLabel());
                    }
                }               
                MetadataService.CustomField customField = new MetadataService.CustomField();
                customField.fullName = objectApiName + '.' + fieldAPi;
                customField.label = ObjectFieldApiMap.get(objectApiName).get(fieldAPi);
                customField.type_x = 'Picklist';
                MetadataService.ValueSet picklistValueSet = new MetadataService.ValueSet();
                MetadataService.ValueSetValuesDefinition valueDefinition = new MetadataService.ValueSetValuesDefinition();
                List < MetadataService.CustomValue > values = new List < MetadataService.CustomValue > ();
                List<MetadataService.PickListValue>  fldPickListValueList =  new List<MetadataService.PickListValue>();
                //Add Existing values back in
                //condition for adding new values 
                //---for loop for adding new values from list-----------                
                for (String picklistValueInsert: picklistValueMap.get(fieldAPi).keySet()) {                    
                    MetadataService.CustomValue existingPLValue = new MetadataService.CustomValue();
                    existingPLValue.fullName = picklistValueInsert;
                    existingPLValue.default_x = false;
                    existingPLValue.label = picklistValueMap.get(fieldAPi).get(picklistValueInsert);
                    values.add(existingPLValue);

                    MetadataService.PickListValue fldPickListValue = new MetadataService.PickListValue();
                    fldPickListValue.fullName = picklistValueInsert;
                    fldPickListValue.default_x = false;
                    fldPickListValueList.add(fldPickListValue); 
                    System.debug(picklistValueInsert);
                }
                objFldMetaPickListValueMap.put(objectApiName+'.'+fieldAPi, fldPickListValueList);                    

                //------for loop for value deactivation.------------
                for (String picklistValue: schemaValueMap.keySet()) {
                    if (!picklistValueMap.get(fieldAPi).containsKey(picklistValue)) { //---condition check. not adding those existing value which is not coming from helper code. 
                        MetadataService.CustomValue existingPLValue = new MetadataService.CustomValue();
                        existingPLValue.fullName = picklistValue;
                        existingPLValue.isActive = False;
                        existingPLValue.default_x = false;
                        existingPLValue.label = schemaValueMap.get(picklistValue);
                        values.add(existingPLValue);
                    }
                }
                valueDefinition.value = values;
                valueDefinition.sorted = false;
                picklistValueSet.valueSetDefinition = valueDefinition;
                customField.valueSet = picklistValueSet;
                schemaValueMap.clear();
                
                  customFieldListToUpdate.add(customField);              
            }
        }
        //Update PicklistFields with new values        
        updateMetadata(service, splitMetadataIntoLists((MetadataService.Metadata[]) customFieldListToUpdate));
        
        List<List<String>> combinedRtValueList = new List<List<String>>();
        //Splitting into size of 10 to avoid limit
        combinedRtValueList = splitListIntoLists(rtValueList);
        List<MetadataService.RecordType> rtMetaList = new List<MetadataService.RecordType>();        
        for(Integer i=0; i<combinedRtValueList.size(); i++){
            if(!Test.isRunningTest())
                //read recordtype
                rtMetaList.addAll((List<MetadataService.RecordType>) service.readMetadata('RecordType', combinedRtValueList[i]).getRecords());            
        }
        Map<String, MetadataService.RecordType> rtMetaRTMap = new Map<String, MetadataService.RecordType>();        
        for(MetadataService.RecordType mRT : rtMetaList){            
            rtMetaRTMap.put(String.valueOf(mRT.fullName).toUpperCase(), mRT);            
        }
        List<MetadataService.RecordType> recordTypeListToUpdate = new List<MetadataService.RecordType>();
        for (String objectApiName: ObjectFieldApiMap.keySet()) {
            for(String rt : ObjectRtMap.get(objectApiName.toUpperCase())){
                MetadataService.RecordType recordType = new MetadataService.RecordType();
                recordType = rtMetaRTMap.get(rt);
                for (String fieldAPi: ObjectFieldApiMap.get(objectApiName).keySet()) { 
                   
                       // initialize the list of record type picklist values
                       MetadataService.RecordTypePicklistValue[] rtPickValues = new MetadataService.RecordTypePicklistValue[]{};
                       MetadataService.RecordTypePicklistValue rtPickValue = new MetadataService.RecordTypePicklistValue();
                       // Create the recordtypepicklist and add the list of picklist fields to the record type
                       rtPickValue.picklist = fieldAPi;
                       rtPickValue.values = objFldMetaPickListValueMap.get(objectApiName+'.'+fieldAPi);
                       System.debug(rtPickValue.values);
                       rtPickValues.add(rtPickValue);
                       if(!Test.isRunningTest())
                           recordType.picklistValues.addAll(rtPickValues);
                                            
                }              
                
        System.debug(recordType.picklistValues.size());
                recordTypeListToUpdate.add(recordType);
            } 
        }
        //Update RecordTypes             
        updateMetadata(service, splitMetadataIntoLists((MetadataService.Metadata[]) recordTypeListToUpdate));        
                         
    }
   
    //-----------create Metadata service----------------
    public static MetadataService.MetadataPort createService() {
        MetadataService.MetadataPort service = new MetadataService.MetadataPort();
        service.SessionHeader = new MetadataService.SessionHeader_element();
        service.SessionHeader.sessionId = UserInfo.getSessionId();
       // service.timeout_x = 40000;
        service.timeout_x = 120000;
        return service;
    }
    
    //readMetadata and updateMetdata has a limit of 10 elements per one callout
    //Spliting Metadata into lists of 10 elements to address above limit
    //-----------Split Master List into small lists of size 10 each----------------
    public static List<List<MetadataService.Metadata>> splitMetadataIntoLists(List<MetadataService.Metadata> listToSplit) {
        List<List<MetadataService.Metadata>> metadataListOfLists = new List<List<MetadataService.Metadata>>();        
        for(Integer i = 0 ; i < (listToSplit.size() / 10)+1 ; i++){
            List<MetadataService.Metadata> lstTemp = new List<MetadataService.Metadata>();
            for(Integer j=(i*10);(j<(i*10)+10) && j<listToSplit.size() ; j++){
                lstTemp.add(listToSplit.get(j));
            }
            metadataListOfLists.add(lstTemp);
        }        
        return metadataListOfLists;
    } 

    //-----------Split Master List into small lists of size 10 each----------------
    public static List<List<String>> splitListIntoLists(List<String> listToSplit) {
        List<List<String>> ListOfLists = new List<List<String>>();        
        for(Integer i = 0 ; i < (listToSplit.size() / 10)+1 ; i++){
            List<String> lstTemp = new List<String>();
            for(Integer j=(i*10);(j<(i*10)+10) && j<listToSplit.size() ; j++){
                lstTemp.add(listToSplit.get(j));
            }
            ListOfLists.add(lstTemp);
        }        
        return ListOfLists;
    }
    
    //-----------Update Metadata----------------
    public static void updateMetadata(MetadataService.MetadataPort service, List<List<MetadataService.Metadata>> metadataToUpdate) {
        for(Integer i=0; i<metadataToUpdate.size(); i++){
            if(!Test.isRunningTest()) {
                List<MetadataService.SaveResult> results = service.updateMetadata(metadataToUpdate[i]);  
                for(MetadataService.SaveResult r : results){
                    system.debug(r.errors);
                }
            }
        }
    }    
}
  • June 03, 2020
  • Like
  • 0
Hi ..
i am trying to write Validation rules, but its conflits..can you pls help some one on this.
can someone pls check and let me know whats wrong here ...or if you have any better pls update

 AND
        (
        OR((Contract_Year_End_Date__c > Effective_Date__c),First_Year_Indicator__c = FALSE), 
        ISCHANGED(Contract_Year_End_Date__c )
        )              
    Error Message :
Cant update Contract Year End Date when first Year Indicator checkbox is False 
     AND
     Contract year end date should be less than Effective Date     
Note : its working as expected.

2)        
AND(
OR(
ISPICKVAL(Contract_type__c,"test1"),
ISPICKVAL(Contract_type__c,"test2")
),
First_Year_Indicator__c = TRUE),
ISCHANGED(Contract_Year_End_Date__c)
)
Error Message :
Contract Year End Date Cant be Edited , When First Year Contract Year checkbox is Checked And contract type picklist is test1 Or test2        
        
        Note : Here i am getting conflits ....displaying first VR Message not display this VR Message and also its not matching my requirment 
        
Thanks
RK
  • April 26, 2020
  • Like
  • 0