• D-Price
  • NEWBIE
  • 0 Points
  • Member since 2012

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

I have a custom object linked to Account. On the custom object I have a picklist with values that I update via the metadata API. The problem is my picklist values are not being displayed because they need to be associated with a record type on the custom object layout. I can query the layout using describeLayout(), but I have no idea how to update the layout for that field to allow the new picklist values to be shown. Does anyone know how to do this?

 

Thanks,

Derek

 

 

Is there a way to query a CustomObject, like Account, to get all it's current metadata settings? It seems like all the examples expect you to create a new CustomObject, set the full name to "Account" and then run update. I've seen no clear examples of how to query the Account metadata analoguous to how you can query for Account records using the EnterpriseConnection query() method.

 

Is there a way to do this?

 

Thanks,

Derek

I am trying to update (add a value to)  a custom picklist that is on our Account. I'm getting confused by Enterprise route and the Metadata route.

 

This post seems close, but I don't want to rename a field just to add a new value:

http://boards.developerforce.com/t5/Java-Development/Does-the-Metadata-API-update-feature-work-with-Picklists/m-p/61641/highlight/true#M4847

 

Here's the code I'm working with using an Enterprise connection:

 

public void updatePicklistSample(EnterpriseConnection connection)
{
	try
	{
		DescribeSObjectResult describeSObjectResult = connection.describeSObject("Account");
		Field[] fields = describeSObjectResult.getFields();
		// create a map of all fields for later lookup
		Map<String, Field> fieldMap = new HashMap<>();
		for(Field field : fields)
			fieldMap.put(field.getName(), field);

		for(Field field : fields)
		{
			// check whether this is my picklist
			if(field.getName().equals("My_Custom_Picklist__c"))
			{
				ArrayList<PicklistEntry> pickListValuesArrayList = new ArrayList<>();
				for(PicklistEntry picklistEntry : field.getPicklistValues())
					pickListValuesArrayList.add(picklistEntry);

				final PicklistEntry entry = new PicklistEntry();
				entry.setActive(true);
				entry.setDefaultValue(false);
				entry.setValue("9999");
				entry.setLabel("9999");
				pickListValuesArrayList.add(entry);
					final PicklistEntry[] plv = pickListValuesArrayList.toArray(new PicklistEntry[pickListValuesArrayList.size()]);
				field.setPicklistValues(plv);
			}
		}
		// What to update here?
		connection.update(????);
	}
	catch(ConnectionException ce)
	{
		fail("Connection failed: " + ce);
	}
}

 I'm just not sure what SObject I need to update.

 

I've also seen this sample that creates a new picklist, but I just want to update a custom field on Account:

http://www.salesforce.com/us/developer/docs/api_meta/index_Left.htm#StartTopic=Content/meta_picklist.htm

 

Does anyone have a clear example on how to do this? Any suggestions?

 

Thanks,

Derek

Is there a way to query a CustomObject, like Account, to get all it's current metadata settings? It seems like all the examples expect you to create a new CustomObject, set the full name to "Account" and then run update. I've seen no clear examples of how to query the Account metadata analoguous to how you can query for Account records using the EnterpriseConnection query() method.

 

Is there a way to do this?

 

Thanks,

Derek