You need to sign in to do that
Don't have an account?
Swati Bhaip
Custom field
I have witten the below code to create Lead Custom Field but it is not work means it will not found the resource .So Please help me to create Custom field
public void createField(String instanceUrl, String accessToken,PrintWriter writer)
{
final MetricRegistry metrics = new MetricRegistry();
// in your app setup, create a pool that's shared for the whole app
RestConnectionPool<Integer> pool = new RestConnectionPoolImpl<Integer>(metrics);
int accId=55;
String instanceUrl1 = instanceUrl.substring("https://".length());
pool.configureOrg(accId, instanceUrl1, accessToken);
RestConnection connection = pool.getRestConnection(accId);
SObject newLead = RestSObjectImpl.getNew("LeadCustomField");
newLead.setField("FieldLabel", "NewLabel");
newLead.setField("DataType", "Picklist");
SaveResult result = null;
try {
result = connection.create(newLead);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
writer.write("Created a lead Custom field with id " + result.getId());
}
public void createField(String instanceUrl, String accessToken,PrintWriter writer)
{
final MetricRegistry metrics = new MetricRegistry();
// in your app setup, create a pool that's shared for the whole app
RestConnectionPool<Integer> pool = new RestConnectionPoolImpl<Integer>(metrics);
int accId=55;
String instanceUrl1 = instanceUrl.substring("https://".length());
pool.configureOrg(accId, instanceUrl1, accessToken);
RestConnection connection = pool.getRestConnection(accId);
SObject newLead = RestSObjectImpl.getNew("LeadCustomField");
newLead.setField("FieldLabel", "NewLabel");
newLead.setField("DataType", "Picklist");
SaveResult result = null;
try {
result = connection.create(newLead);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
writer.write("Created a lead Custom field with id " + result.getId());
}