• Swagat.Tushar
  • NEWBIE
  • 55 Points
  • Member since 2013

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

Hi All,

Requirement: To update four picklist field values with dependencies on any object. As the numbers of picklist values are high it’s difficult to manage the Field Dependencies manually.

 

Product Family

Product Line

Product Module

Product Version

 

Design Approach: So we planned to go for customization. We used four custom settings to store the picklist values. Then update the picklist fields values using Metadata API.

Below are the design of four custom settings.

Product Family

Family1

Family2

Family3

 

Product Line

Family1 - Line1

Family2 - Line2

Family3 - Line3

 

Product Module

Line1 - Module1

Line1 - Module2

Line2 - Module2

 

Product Version

Line1 - Version1

Line1 - Version1

Line2 - Version2

 

Problem: Though the above design works for less volume of data, when i am trying to update 1000 picklist values the system is not updating the values. I tried to debug my code but there is also an inconsistency in Debug Log or Debug Log is not showing completely.

 

I have posted about this inconsistency here:

http://boards.developerforce.com/t5/Apex-Code-Development/Inconsistent-Debug-Log-Debug-Log-not-showing/td-p/695633

 

Here is the code for the VF/Controller from where I am trying to invoke the Metadata update methods.

<apex:page controller="UpdatePicklist">
<apex:pageMessages ></apex:pageMessages>
    <apex:form >
        Add picklist values with field dependencies
        <apex:commandButton value="Product Family" id="theButtonFamily" Action="{!updatePicklistField_Product_Family}"/>
        <apex:commandButton value="Product Line" id="theButtonLine" Action="{!updatePicklistField_Product_Line}"/>
        <apex:commandButton value="Product Module" id="theButtonModule" Action="{!updatePicklistField_Product_Module}"/>
        <apex:commandButton value="Product Version" id="theButtonVersion" Action="{!updatePicklistField_Product_Version}"/>
    </apex:form>   
</apex:page>

 

Apex class/Controller

public class UpdatePicklist{
    public static MetadataService.MetadataPort createService(){
        MetadataService.MetadataPort service = new MetadataService.MetadataPort();
        service.SessionHeader = new MetadataService.SessionHeader_element();
        service.SessionHeader.sessionId = UserInfo.getSessionId();
        return service;
    }
    
    //Update Product Family
    public PageReference updatePicklistField_Product_Family() {
        List<Product_Family__c> lstProduct_Family = Product_Family__c.getall().values();
        MetadataService.MetadataPort service = createService();
        MetadataService.CustomField customField = new MetadataService.CustomField();
        customField.fullName = 'Case.Primary_Product_Family__c';
        customField.label = 'Primary Product Family';
        customField.type_x = 'Picklist';
    
        metadataservice.Picklist pt = new metadataservice.Picklist();
        pt.sorted= true;
        pt.picklistValues = new list<metadataservice.PicklistValue>();
            
        for(Product_Family__c objPicklistValues : lstProduct_Family){
            metadataservice.PicklistValue plValue = new metadataservice.PicklistValue();
            plValue.fullName=objPicklistValues.Family__c;
            plValue.default_x=false ;
            pt.picklistValues.add(plValue);       
        }
        customField.picklist = pt ;

        MetadataService.UpdateMetadata ut = new MetadataService.UpdateMetadata();
        ut.currentName='Case.Primary_Product_Family__c';
        ut.metadata= customField;
        MetadataService.AsyncResult[] results = service.updateMetadata(new List<MetadataService.updateMetadata> {ut});
        system.debug('xxxxxx'+results);
        system.debug('xxxxxx'+results[0].State);
        //check if async call completed
        /*if (results[0].State == 'Completed'){
            updatePicklistField_Product_Line();
        }*/
        return null;
    }
    
    //Update Product Line
    public PageReference updatePicklistField_Product_Line() {
        List<Product_Line__c> lstProduct_Line = Product_Line__c.getall().values();
        MetadataService.MetadataPort service = createService();
        MetadataService.CustomField customField = new MetadataService.CustomField(); 
        customField.fullName = 'Case.Primary_Product_Line__c';
        customField.label = 'Primary Product Line';
        customField.type_x = 'Picklist'; 
        
        metadataservice.Picklist pt = new metadataservice.Picklist();
        pt.sorted= true;
        pt.picklistValues = new list<metadataservice.PicklistValue>();
        pt.controllingField='Primary_Product_Family__c'; //***** name of controlling field . if picklist has contrlloing field , this must be asssigned . else field dependency will be deleted
        //************************
        
        Map<String, List<String>> mapDepValContVal = new Map<String, List<String>>();
        for(Product_Line__c prdLine : lstProduct_Line){
            List<String> lstControllingValues = mapDepValContVal.get(prdLine.Line__c);
            if(lstControllingValues == null)
                lstControllingValues = new list<String>();
            lstControllingValues.add(prdLine.Family__c);
            mapDepValContVal.put(prdLine.Line__c, lstControllingValues);
        }
        system.debug('xxxxxmapDepValContVal'+mapDepValContVal);
        
        for(String strDepVal : mapDepValContVal.keySet()){
            metadataservice.PicklistValue plValue = new metadataservice.PicklistValue();
            plValue.fullName=strDepVal;
            plValue.default_x=false ;
            plValue.controllingFieldValues = mapDepValContVal.get(strDepVal);
            pt.picklistValues.add(plValue);       
        } 
        customField.picklist = pt ;       
        
        MetadataService.UpdateMetadata ut = new MetadataService.UpdateMetadata();
        ut.currentName='Case.Primary_Product_Line__c';
        ut.metadata=customField;
        MetadataService.AsyncResult[] results = service.updateMetadata(new List<MetadataService.updateMetadata> {ut});
        
        //check if async call completed
        /*if (results[0].State == 'Completed'){
            updatePicklistField_Product_Module();
            updatePicklistField_Product_Version();    
        }*/
        return null;
    }
    
    //Update Product Module
    public PageReference updatePicklistField_Product_Module() {
        system.debug('cccccupdatePicklistField_Product_Module');
        //List<Product_Module__c> lstProduct_Module = Product_Module__c.getall().values();
        List<Product_Module__c> lstProduct_Module = [Select Name, Module__c, Line__c from Product_Module__c limit 200];
        system.debug('ccccclstProduct_Module'+lstProduct_Module);
        MetadataService.MetadataPort service;
        try{
            service = createService();
            system.debug('ccccc-1');
        }
        Catch(Exception ex){
         system.debug('ccccc0'+ex);
        }
        system.debug('ccccc1');
        MetadataService.CustomField customField = new MetadataService.CustomField(); 
        customField.fullName = 'Case.Primary_Product_Module__c';
        customField.label = 'Primary Product Module';
        customField.type_x = 'Picklist'; 
        system.debug('ccccc2');
        
        metadataservice.Picklist pt = new metadataservice.Picklist();
        pt.sorted= true;
        pt.picklistValues = new list<metadataservice.PicklistValue>();
        pt.controllingField='Primary_Product_Line__c'; //***** name of controlling field . if picklist has contrlloing field , this must be asssigned . else field dependency will be deleted
        //************************
        
        system.debug('ccccclstProduct_Module'+lstProduct_Module.size());
        Map<String, List<String>> mapDepValContVal = new Map<String, List<String>>();
        for(Product_Module__c prdModule : lstProduct_Module){
            system.debug('cccccprdModule'+prdModule);
            List<String> lstControllingValues = mapDepValContVal.get(prdModule.Module__c);
            if(lstControllingValues == null)
                lstControllingValues = new list<String>();
            lstControllingValues.add(prdModule.Line__c);
            system.debug('ccccclstControllingValues'+lstControllingValues);
            mapDepValContVal.put(prdModule.Module__c, lstControllingValues);
        }
        system.debug('cccccmapDepValContVal'+mapDepValContVal.size());
        
        for(String strDepVal : mapDepValContVal.keySet()){
            system.debug('cccccstrDepVal'+strDepVal);
            metadataservice.PicklistValue plValue = new metadataservice.PicklistValue();
            plValue.fullName=strDepVal;
            plValue.default_x=false ;
            plValue.controllingFieldValues = mapDepValContVal.get(strDepVal);
            pt.picklistValues.add(plValue);       
        } 
        system.debug('ccccc3');
        customField.picklist = pt ;  
        system.debug('ccccc4');     
        
        MetadataService.UpdateMetadata ut = new MetadataService.UpdateMetadata();
        ut.currentName='Case.Primary_Product_Module__c';
        ut.metadata=customField;
        MetadataService.AsyncResult[] results = service.updateMetadata(new List<MetadataService.updateMetadata> {ut});
        return null;
    }
    
    //Update Product Version
    public PageReference updatePicklistField_Product_Version() {
        system.debug('dddddupdatePicklistField_Product_Version');
        //List<Product_Version__c> lstProduct_Version = Product_Version__c.getall().values();
        List<Product_Version__c> lstProduct_Version = [Select Name, Version__c, Line__c from Product_Version__c limit 100];
        system.debug('dddddlstProduct_Version'+lstProduct_Version);
        MetadataService.MetadataPort service;
        try{
            service = createService();
            system.debug('ddddd-1');
        }
        Catch(Exception ex){
         system.debug('ddddd0'+ex);
        }
        system.debug('ddddd1');
        MetadataService.CustomField customField = new MetadataService.CustomField(); 
        customField.fullName = 'Case.Primary_Product_Version__c';
        customField.label = 'Primary Product Version';
        customField.type_x = 'Picklist'; 
        system.debug('ddddd2');
        
        metadataservice.Picklist pt = new metadataservice.Picklist();
        pt.sorted= true;
        pt.picklistValues = new list<metadataservice.PicklistValue>();
        pt.controllingField='Primary_Product_Line__c'; //***** name of controlling field . if picklist has contrlloing field , this must be asssigned . else field dependency will be deleted
        //************************
        
        system.debug('dddddlstProduct_Version'+lstProduct_Version.size());
        Map<String, List<String>> mapDepValContVal = new Map<String, List<String>>();
        for(Product_Version__c prdVersion : lstProduct_Version){
            List<String> lstControllingValues = mapDepValContVal.get(prdVersion.Version__c);
            if(lstControllingValues == null)
                lstControllingValues = new list<String>();
            lstControllingValues.add(prdVersion.Line__c);
            system.debug('dddddlstControllingValues'+lstControllingValues);
            mapDepValContVal.put(prdVersion.Version__c, lstControllingValues);
        }
        system.debug('dddddmapDepValContVal'+mapDepValContVal.size());
        
        for(String strDepVal : mapDepValContVal.keySet()){
            metadataservice.PicklistValue plValue = new metadataservice.PicklistValue();
            plValue.fullName=strDepVal;
            plValue.default_x=false ;
            plValue.controllingFieldValues = mapDepValContVal.get(strDepVal);
            pt.picklistValues.add(plValue);       
        } 
        system.debug('ddddd3');
        customField.picklist = pt ;  
        system.debug('ddddd4');     
        
        MetadataService.UpdateMetadata ut = new MetadataService.UpdateMetadata();
        ut.currentName='Case.Primary_Product_Version__c';
        ut.metadata=customField;
        MetadataService.AsyncResult[] results = service.updateMetadata(new List<MetadataService.updateMetadata> {ut});
        return null;
    }
}

 

Any words of advice or any other approach/solution?

 

Regards

Swagat

 

 

 

I am trying to log some values for my apex class(using system.debug) but the logs are just not printing.

This is what is happening:

  1. I am pressing a button that gets values from custom setting and update that values to a picklist field values usinf MetadataAPI.
  2. When the button action method runs, I am using System.debug to check the values.
  3. Confusingly, some of the logs are just not capturing. For example, I get the last debug statement result of the method, but not the first one (on the first line of the method). How can the last line print, but not the first?
  4. If I am doing the operation for small set of data then all debug statements are returning perfectly. The issue comes up when I do the operations for large volume of data(i.e. 1000 records)

Hello,

Requirement: To update four picklist field values with dependencies. As the numbers of picklist values are high it’s difficult to manage the Field Dependencies manually.

 

Product Family

Product Line

Product Module

Product Version

 

Design Approach: So we planned to go for customization. We used four custom settings to store the picklist values. Then update the picklist fields values using Metadata API. Below are the design of four custom settings.

Product Family

Family1

Family2

Family3

 

Product Line

Family1 - Line1

Family2 - Line2

Family3 - Line3

 

Product Module

Line1 - Module1

Line1 - Module2

Line2 - Module2

 

Product Version

Module1 - Version1

Module2 - Version1

Module2 - Version2

 

Problem: Though the above design works for less volume of data, I am getting “System.LimitException: Apex CPU time limit exceeded” error when the number of picklist values is high (i.e. more than 1000).

 

I have generated a Metadata Service class from the MetadataAPI WSDL.

I need a map of following format to pass into "UpdateMetadata" method(in Metadata Service class).

Map<String, List<String>> OR Map<DependantValue, List<ControllingValues>>

 

To get the data in above format from custom setting, I am using below code.

 

Set<String> setDependantValue = new Set<String>();
        for(Product_Line__c objPicklistValues : lstProduct_Line){
            setDependantValue.add(objPicklistValues.Product_Line_Name__c);
        }
        Map<String, List<String>> mapDependantControllingValue = new Map<String, List<String>>();
        for(String objDepVal : setDependantValue){
            List<String> lstControllingValues = new List<String>();
            for(Product_Line__c objPicklistValues : lstProduct_Line){
                if(objDepVal == objPicklistValues.Product_Line_Name__c){
                    lstControllingValues.add(objPicklistValues.Product_Family_Name__c);
                }
            }
            mapDependantControllingValue.put(objDepVal, lstControllingValues);
        }

 

I think the error is coming due to FOR inside FOR loop.

Is there any other way to optimize the code or any solution?


Thank you

Swagat

 

 

The customer portal user account is getting locked after 3 wrong password attempts. But when customer portal user perform the forgot password steps, he is able to receive a mail with temporary password and able to unlock the account.

 

This is not in case of internal salesforce user. Internal salesforce user can login only after Lockout effective period is over or the account is unlicked by a system admin. We want to implement same password policies for customer portal user too.

I have a filtered contact field (for account) on Case object. While creating a new case First I select the account then the related contact. If I remove the account and select same account again, i am getting this error.

 

Contact A is no longer valid with your selections

 

Hi All,

Requirement: To update four picklist field values with dependencies on any object. As the numbers of picklist values are high it’s difficult to manage the Field Dependencies manually.

 

Product Family

Product Line

Product Module

Product Version

 

Design Approach: So we planned to go for customization. We used four custom settings to store the picklist values. Then update the picklist fields values using Metadata API.

Below are the design of four custom settings.

Product Family

Family1

Family2

Family3

 

Product Line

Family1 - Line1

Family2 - Line2

Family3 - Line3

 

Product Module

Line1 - Module1

Line1 - Module2

Line2 - Module2

 

Product Version

Line1 - Version1

Line1 - Version1

Line2 - Version2

 

Problem: Though the above design works for less volume of data, when i am trying to update 1000 picklist values the system is not updating the values. I tried to debug my code but there is also an inconsistency in Debug Log or Debug Log is not showing completely.

 

I have posted about this inconsistency here:

http://boards.developerforce.com/t5/Apex-Code-Development/Inconsistent-Debug-Log-Debug-Log-not-showing/td-p/695633

 

Here is the code for the VF/Controller from where I am trying to invoke the Metadata update methods.

<apex:page controller="UpdatePicklist">
<apex:pageMessages ></apex:pageMessages>
    <apex:form >
        Add picklist values with field dependencies
        <apex:commandButton value="Product Family" id="theButtonFamily" Action="{!updatePicklistField_Product_Family}"/>
        <apex:commandButton value="Product Line" id="theButtonLine" Action="{!updatePicklistField_Product_Line}"/>
        <apex:commandButton value="Product Module" id="theButtonModule" Action="{!updatePicklistField_Product_Module}"/>
        <apex:commandButton value="Product Version" id="theButtonVersion" Action="{!updatePicklistField_Product_Version}"/>
    </apex:form>   
</apex:page>

 

Apex class/Controller

public class UpdatePicklist{
    public static MetadataService.MetadataPort createService(){
        MetadataService.MetadataPort service = new MetadataService.MetadataPort();
        service.SessionHeader = new MetadataService.SessionHeader_element();
        service.SessionHeader.sessionId = UserInfo.getSessionId();
        return service;
    }
    
    //Update Product Family
    public PageReference updatePicklistField_Product_Family() {
        List<Product_Family__c> lstProduct_Family = Product_Family__c.getall().values();
        MetadataService.MetadataPort service = createService();
        MetadataService.CustomField customField = new MetadataService.CustomField();
        customField.fullName = 'Case.Primary_Product_Family__c';
        customField.label = 'Primary Product Family';
        customField.type_x = 'Picklist';
    
        metadataservice.Picklist pt = new metadataservice.Picklist();
        pt.sorted= true;
        pt.picklistValues = new list<metadataservice.PicklistValue>();
            
        for(Product_Family__c objPicklistValues : lstProduct_Family){
            metadataservice.PicklistValue plValue = new metadataservice.PicklistValue();
            plValue.fullName=objPicklistValues.Family__c;
            plValue.default_x=false ;
            pt.picklistValues.add(plValue);       
        }
        customField.picklist = pt ;

        MetadataService.UpdateMetadata ut = new MetadataService.UpdateMetadata();
        ut.currentName='Case.Primary_Product_Family__c';
        ut.metadata= customField;
        MetadataService.AsyncResult[] results = service.updateMetadata(new List<MetadataService.updateMetadata> {ut});
        system.debug('xxxxxx'+results);
        system.debug('xxxxxx'+results[0].State);
        //check if async call completed
        /*if (results[0].State == 'Completed'){
            updatePicklistField_Product_Line();
        }*/
        return null;
    }
    
    //Update Product Line
    public PageReference updatePicklistField_Product_Line() {
        List<Product_Line__c> lstProduct_Line = Product_Line__c.getall().values();
        MetadataService.MetadataPort service = createService();
        MetadataService.CustomField customField = new MetadataService.CustomField(); 
        customField.fullName = 'Case.Primary_Product_Line__c';
        customField.label = 'Primary Product Line';
        customField.type_x = 'Picklist'; 
        
        metadataservice.Picklist pt = new metadataservice.Picklist();
        pt.sorted= true;
        pt.picklistValues = new list<metadataservice.PicklistValue>();
        pt.controllingField='Primary_Product_Family__c'; //***** name of controlling field . if picklist has contrlloing field , this must be asssigned . else field dependency will be deleted
        //************************
        
        Map<String, List<String>> mapDepValContVal = new Map<String, List<String>>();
        for(Product_Line__c prdLine : lstProduct_Line){
            List<String> lstControllingValues = mapDepValContVal.get(prdLine.Line__c);
            if(lstControllingValues == null)
                lstControllingValues = new list<String>();
            lstControllingValues.add(prdLine.Family__c);
            mapDepValContVal.put(prdLine.Line__c, lstControllingValues);
        }
        system.debug('xxxxxmapDepValContVal'+mapDepValContVal);
        
        for(String strDepVal : mapDepValContVal.keySet()){
            metadataservice.PicklistValue plValue = new metadataservice.PicklistValue();
            plValue.fullName=strDepVal;
            plValue.default_x=false ;
            plValue.controllingFieldValues = mapDepValContVal.get(strDepVal);
            pt.picklistValues.add(plValue);       
        } 
        customField.picklist = pt ;       
        
        MetadataService.UpdateMetadata ut = new MetadataService.UpdateMetadata();
        ut.currentName='Case.Primary_Product_Line__c';
        ut.metadata=customField;
        MetadataService.AsyncResult[] results = service.updateMetadata(new List<MetadataService.updateMetadata> {ut});
        
        //check if async call completed
        /*if (results[0].State == 'Completed'){
            updatePicklistField_Product_Module();
            updatePicklistField_Product_Version();    
        }*/
        return null;
    }
    
    //Update Product Module
    public PageReference updatePicklistField_Product_Module() {
        system.debug('cccccupdatePicklistField_Product_Module');
        //List<Product_Module__c> lstProduct_Module = Product_Module__c.getall().values();
        List<Product_Module__c> lstProduct_Module = [Select Name, Module__c, Line__c from Product_Module__c limit 200];
        system.debug('ccccclstProduct_Module'+lstProduct_Module);
        MetadataService.MetadataPort service;
        try{
            service = createService();
            system.debug('ccccc-1');
        }
        Catch(Exception ex){
         system.debug('ccccc0'+ex);
        }
        system.debug('ccccc1');
        MetadataService.CustomField customField = new MetadataService.CustomField(); 
        customField.fullName = 'Case.Primary_Product_Module__c';
        customField.label = 'Primary Product Module';
        customField.type_x = 'Picklist'; 
        system.debug('ccccc2');
        
        metadataservice.Picklist pt = new metadataservice.Picklist();
        pt.sorted= true;
        pt.picklistValues = new list<metadataservice.PicklistValue>();
        pt.controllingField='Primary_Product_Line__c'; //***** name of controlling field . if picklist has contrlloing field , this must be asssigned . else field dependency will be deleted
        //************************
        
        system.debug('ccccclstProduct_Module'+lstProduct_Module.size());
        Map<String, List<String>> mapDepValContVal = new Map<String, List<String>>();
        for(Product_Module__c prdModule : lstProduct_Module){
            system.debug('cccccprdModule'+prdModule);
            List<String> lstControllingValues = mapDepValContVal.get(prdModule.Module__c);
            if(lstControllingValues == null)
                lstControllingValues = new list<String>();
            lstControllingValues.add(prdModule.Line__c);
            system.debug('ccccclstControllingValues'+lstControllingValues);
            mapDepValContVal.put(prdModule.Module__c, lstControllingValues);
        }
        system.debug('cccccmapDepValContVal'+mapDepValContVal.size());
        
        for(String strDepVal : mapDepValContVal.keySet()){
            system.debug('cccccstrDepVal'+strDepVal);
            metadataservice.PicklistValue plValue = new metadataservice.PicklistValue();
            plValue.fullName=strDepVal;
            plValue.default_x=false ;
            plValue.controllingFieldValues = mapDepValContVal.get(strDepVal);
            pt.picklistValues.add(plValue);       
        } 
        system.debug('ccccc3');
        customField.picklist = pt ;  
        system.debug('ccccc4');     
        
        MetadataService.UpdateMetadata ut = new MetadataService.UpdateMetadata();
        ut.currentName='Case.Primary_Product_Module__c';
        ut.metadata=customField;
        MetadataService.AsyncResult[] results = service.updateMetadata(new List<MetadataService.updateMetadata> {ut});
        return null;
    }
    
    //Update Product Version
    public PageReference updatePicklistField_Product_Version() {
        system.debug('dddddupdatePicklistField_Product_Version');
        //List<Product_Version__c> lstProduct_Version = Product_Version__c.getall().values();
        List<Product_Version__c> lstProduct_Version = [Select Name, Version__c, Line__c from Product_Version__c limit 100];
        system.debug('dddddlstProduct_Version'+lstProduct_Version);
        MetadataService.MetadataPort service;
        try{
            service = createService();
            system.debug('ddddd-1');
        }
        Catch(Exception ex){
         system.debug('ddddd0'+ex);
        }
        system.debug('ddddd1');
        MetadataService.CustomField customField = new MetadataService.CustomField(); 
        customField.fullName = 'Case.Primary_Product_Version__c';
        customField.label = 'Primary Product Version';
        customField.type_x = 'Picklist'; 
        system.debug('ddddd2');
        
        metadataservice.Picklist pt = new metadataservice.Picklist();
        pt.sorted= true;
        pt.picklistValues = new list<metadataservice.PicklistValue>();
        pt.controllingField='Primary_Product_Line__c'; //***** name of controlling field . if picklist has contrlloing field , this must be asssigned . else field dependency will be deleted
        //************************
        
        system.debug('dddddlstProduct_Version'+lstProduct_Version.size());
        Map<String, List<String>> mapDepValContVal = new Map<String, List<String>>();
        for(Product_Version__c prdVersion : lstProduct_Version){
            List<String> lstControllingValues = mapDepValContVal.get(prdVersion.Version__c);
            if(lstControllingValues == null)
                lstControllingValues = new list<String>();
            lstControllingValues.add(prdVersion.Line__c);
            system.debug('dddddlstControllingValues'+lstControllingValues);
            mapDepValContVal.put(prdVersion.Version__c, lstControllingValues);
        }
        system.debug('dddddmapDepValContVal'+mapDepValContVal.size());
        
        for(String strDepVal : mapDepValContVal.keySet()){
            metadataservice.PicklistValue plValue = new metadataservice.PicklistValue();
            plValue.fullName=strDepVal;
            plValue.default_x=false ;
            plValue.controllingFieldValues = mapDepValContVal.get(strDepVal);
            pt.picklistValues.add(plValue);       
        } 
        system.debug('ddddd3');
        customField.picklist = pt ;  
        system.debug('ddddd4');     
        
        MetadataService.UpdateMetadata ut = new MetadataService.UpdateMetadata();
        ut.currentName='Case.Primary_Product_Version__c';
        ut.metadata=customField;
        MetadataService.AsyncResult[] results = service.updateMetadata(new List<MetadataService.updateMetadata> {ut});
        return null;
    }
}

 

Any words of advice or any other approach/solution?

 

Regards

Swagat

 

 

 

I am trying to log some values for my apex class(using system.debug) but the logs are just not printing.

This is what is happening:

  1. I am pressing a button that gets values from custom setting and update that values to a picklist field values usinf MetadataAPI.
  2. When the button action method runs, I am using System.debug to check the values.
  3. Confusingly, some of the logs are just not capturing. For example, I get the last debug statement result of the method, but not the first one (on the first line of the method). How can the last line print, but not the first?
  4. If I am doing the operation for small set of data then all debug statements are returning perfectly. The issue comes up when I do the operations for large volume of data(i.e. 1000 records)

Hello,

Requirement: To update four picklist field values with dependencies. As the numbers of picklist values are high it’s difficult to manage the Field Dependencies manually.

 

Product Family

Product Line

Product Module

Product Version

 

Design Approach: So we planned to go for customization. We used four custom settings to store the picklist values. Then update the picklist fields values using Metadata API. Below are the design of four custom settings.

Product Family

Family1

Family2

Family3

 

Product Line

Family1 - Line1

Family2 - Line2

Family3 - Line3

 

Product Module

Line1 - Module1

Line1 - Module2

Line2 - Module2

 

Product Version

Module1 - Version1

Module2 - Version1

Module2 - Version2

 

Problem: Though the above design works for less volume of data, I am getting “System.LimitException: Apex CPU time limit exceeded” error when the number of picklist values is high (i.e. more than 1000).

 

I have generated a Metadata Service class from the MetadataAPI WSDL.

I need a map of following format to pass into "UpdateMetadata" method(in Metadata Service class).

Map<String, List<String>> OR Map<DependantValue, List<ControllingValues>>

 

To get the data in above format from custom setting, I am using below code.

 

Set<String> setDependantValue = new Set<String>();
        for(Product_Line__c objPicklistValues : lstProduct_Line){
            setDependantValue.add(objPicklistValues.Product_Line_Name__c);
        }
        Map<String, List<String>> mapDependantControllingValue = new Map<String, List<String>>();
        for(String objDepVal : setDependantValue){
            List<String> lstControllingValues = new List<String>();
            for(Product_Line__c objPicklistValues : lstProduct_Line){
                if(objDepVal == objPicklistValues.Product_Line_Name__c){
                    lstControllingValues.add(objPicklistValues.Product_Family_Name__c);
                }
            }
            mapDependantControllingValue.put(objDepVal, lstControllingValues);
        }

 

I think the error is coming due to FOR inside FOR loop.

Is there any other way to optimize the code or any solution?


Thank you

Swagat

 

 

The customer portal user account is getting locked after 3 wrong password attempts. But when customer portal user perform the forgot password steps, he is able to receive a mail with temporary password and able to unlock the account.

 

This is not in case of internal salesforce user. Internal salesforce user can login only after Lockout effective period is over or the account is unlicked by a system admin. We want to implement same password policies for customer portal user too.

I have a filtered contact field (for account) on Case object. While creating a new case First I select the account then the related contact. If I remove the account and select same account again, i am getting this error.

 

Contact A is no longer valid with your selections

 

Hi All,

 

I have created a force.com site.Now as the users try to login to this site, there are getting this SSL Certifiacte error.

 

If we click on "Procede Anyway", then the user will be allowed into the site.

 

How should I resolve this for the entire Organisatiion users.

 

Thanks,

Vijay

We have a webservice that sometimes gets inundated with requests from an APEX trigger we have.  So, we wrote a .NET batch program to do the requests via API through SFDC with a 45 second delay between requests.  We'd like to make that a Batch APEX, however, I can't find any way to make the APEX code pause between submittals.  I tried a loop checking on the time, but that causes 200K worth of script statements which exceeds governor limits too.

 

Does anyone have any ideas?

 

Thanx!