• AncaComaneciu
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
I am using the apex-mdapi MetadataService class to update the picklist values from Apex. However i keep getting teh following error on the update (List<MetadataService.SaveResult> lstResults = service.updateMetadata( new MetadataService.Metadata[] { customField });), not on read:
WebService returned a SOAP Fault: Must specify a type attribute value for the metadata element

The code i used is the one from below:
String picklistapiname = 'Lead.Status__c';
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();

MetadataService.CustomField customField = (MetadataService.CustomField) service.readMetadata('CustomField', new String[] { picklistapiname}).getRecords()[0];

// For each on: customField > Get valueset > Get valueSetDefinition > get values
for(MetadataService.CustomValue objCustomValue : customField.valueSet.valueSetDefinition.value){
    if(objCustomValue.fullName == 'Closed'){ // API Name
        objCustomValue.fullName = 'Close'; // New API Value
        objCustomValue.label = 'Close'; // New Label value
    }
}
// Update 
List<MetadataService.SaveResult> lstResults = service.updateMetadata( new MetadataService.Metadata[] { customField });

for (MetadataService.SaveResult objResult : lstResults) {
    if (objResult.success) {
        System.debug('Successfully updated');
    }
    else {
        if(objResult.errors.size() > 0){
            System.debug('eror : ' + objResult.errors[0].message);
        }
    }
}
I also updated the CustomField class to include
public String type = 'CustomField';
public String fullName;
private String[] fullName_type_info = new String[]{'fullName',SOAP_M_URI,null,'0','1','false'};
Can someone please help? Thank you.

 
Is it possible to dynamically set class variable value?

I have a dynamyc form that should send the data to an external service (SOAP). The fields that are necessary depend on specific settings and can change. Can we set the Object attributes dynamically similar to how it's possible with sObject?

I would like to be able yo do someting like this:
public class dynForm {
    public String att1;
    public String att2;
    //additional attributes
}
dynForm myObject = new dynForm();
myObject.put('att1', 'value1');
I have 2 lightning components that do HttpRequest:
- 1st components requests some infrmation that needs to be saved in Salesforce
- 2nd component requests some information for display purposes

Use cases:
- just 1st component in a SFDC community - all works ok
- just 2nd component in a SFDC community - all works ok
- 2nd component and then 1st component in a SFDC community - all works ok
- 1st component and then 2nd component in a SFDC community - it gives me the "You have uncommitted work pending. Please commit or rollback before calling out" error.

It seems that all aura code is executed on one single thread instead of having one thread for each lightning component.

I tried to do the update in a future call but it still fails...
Does anyone knows how i could fix this?
I have 2 lightning components that do HttpRequest:
- 1st components requests some infrmation that needs to be saved in Salesforce
- 2nd component requests some information for display purposes

Use cases:
- just 1st component in a SFDC community - all works ok
- just 2nd component in a SFDC community - all works ok
- 2nd component and then 1st component in a SFDC community - all works ok
- 1st component and then 2nd component in a SFDC community - it gives me the "You have uncommitted work pending. Please commit or rollback before calling out" error.

It seems that all aura code is executed on one single thread instead of having one thread for each lightning component.

I tried to do the update in a future call but it still fails...
Does anyone knows how i could fix this?
Does this:
var result = sforce.apex.execute(.....)
produce a page hit when it is called on a Site page?

Thanks!