function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NewtecNewtec 

metadata api GlobalValueSet : Edit (java)

Hi,

Trying to change values in a global picklist value set but when reading the metadata the CustomValue object is not filled. We only get the Value itself (label and name) but the isActiven, color ,... fields are not set :

Result :

[ReadResult  records='{[1][GlobalValueSet [Metadata  fullName='Application'
]
 customValue='{[84][CustomValue [Metadata  fullName='A01'
]
 color='null'
 _default='false'
 description='null'
 isActive='false'
 label='null'
]
]

=> This value is certainly active in salesforce.

If we change the CustomValue object to isActive = true, and execute an update to salesforce, this error message is given :

"CustomField not found."

This is the method that reads the metadata of a GlobalValueSet 
 
private GlobalValueSet readGlobalValueSet(String picklist) throws Exception {
		GlobalValueSet affectsVersions = new GlobalValueSet();
		
		try{

			MetadataConnection metadataConnection = sfmcon.getConnection();
			
			ReadResult readResult = metadataConnection.readMetadata("GlobalValueSet", new String[] {picklist});
			//log.info(readResult.toString());
			Metadata[] mdInfo = readResult.getRecords();
			if (mdInfo.length == 1) {
				affectsVersions = (GlobalValueSet) mdInfo[0];
			}
			else {
				log.info("None or multiple components");		
			}
		}
		catch(ConnectionException e){
			e.printStackTrace();
		}
		
		return affectsVersions;
	}
Probably doing something wrong here, don't think it is authorization related as the user has Modify everything rights.

with regards
NewtecNewtec
Anybody ?