• Leelakrishna Muniraj
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
How do I add new values to an existing picklist? in apex coding
consider this picklist field in any object.
Existing picklist having city = xxx
                                               yyy

How should i add new city picklist value zzz then my expected is
 Existing picklist having city = xxx
                                                yyy                                            
                                                zzz


-------------------------------Following Code I Tried----------------------
public class Test_MetadataAPI {
    public static MetadataService.MetadataPort createService(){
        MetadataService.MetadataPort service = new MetadataService.MetadataPort();
        service.SessionHeader = new MetadataService.SessionHeader_element();
        service.SessionHeader.sessionId = UserInfo.getSessionId();
        return service;
    }
public static void UpdatePicklist(){
        MetadataService.MetadataPort service = createService();
    
        MetadataService.CustomField customField = new MetadataService.CustomField();
        customField.fullName = 'Contact' + '.testPicklist__c';
        customField.label = 'testPicklist';
        customField.type_x = 'Picklist';
        customField.description = '';
        
        // Create the valueSet for picklist type
        MetadataService.ValueSet picklistValueSet = new MetadataService.ValueSet();
        
        //For each ValueSet, we have either ValueSetValuesDefinition or ValueSettings and some other attributes
        MetadataService.ValueSetValuesDefinition valueDefinition = new MetadataService.ValueSetValuesDefinition();
        
        List<MetadataService.CustomValue> values = new List<MetadataService.CustomValue>();
        
        MetadataService.CustomValue customValue1= new MetadataService.CustomValue();
        customValue1.fullName='NewTestOne';// API Name of picklist value
        //customValue1.default = true;//true/false;
        customValue1.description = 'just testing';
        customValue1.isActive = true;//true/false;
        customValue1.label = 'NewTestOne';
        values.add(customValue1);
        
        // it will be list of CustomValue
        valueDefinition.value = values;
        valueDefinition.sorted = false;//false/true;
        
        // Set  the valueSetDefinition
        picklistValueSet.valueSetDefinition = valueDefinition;
        
        // Set the valueSet for picklist type
        customField.valueSet = picklistValueSet;
        //customFields.add(customField);
        
        MetadataService.SaveResult[] results = service.updateMetadata(new List<MetadataService.Metadata> {customField});
    }    
}
 
I need to get the current time but to be in type DateTime.

I use:
DateTime now = System.now();
but it returns wrong time.

I execute the code in 2017-08-04 00:38:46 AM

but it returns
00:38:46:023 USER_DEBUG [138]|DEBUG|now 2017-08-03 21:38:46
How can I get my correct current local time 2017-08-04 00:38:46?

I had even tried with:
DateTime now = DateTime.parse(System.Now().format());
but I still get wrong time.
01:10:09:021 USER_DEBUG [139]|DEBUG|now 2017-08-03 22:10:00
How can I get the correct current local time?



 
Call to webservice at https://na17.salesforce.com/services/Soap/u/28.0/00Do0000000Zb9Z failed. Reported error:
The webservice call failed. The web service returned a SOAP Fault:
Code: soapenv:Client
Message: '02/03/2015 11:20 AM' is not a valid value for the type xsd:dateTime


I use jitterbit to get all of my order/customer data into Salesforce for CRM.

All of my OrderTime on orders read as: 12/30/1899 3:25 PM


I have been trying to fix this using CVTDate

FOrmula such as:
<trans>
CVTDate(Now(),"?m/?d/yyyy HH:MM:SS AP", "mm/dd/yyyy HH:MM AP")
</trans>


My ordertime data from my db reads as 2/3/2015 9:30:35 AM

What CVTDate line can I use that works? Ive tried like 8 ways.