You need to sign in to do that
Don't have an account?

Can not specify 'precision' for a CustomField of type Text
private void createCustomField(CustomObject cObj)
{
//Verify that we are already authenticated, if not
//call the login function to do so
if (!loggedIn)
{
if (!login())
return;
}
try
{
string fieldName = "NewField";
CustomField cf = new CustomField();
cf.description = "Test Field";
cf.fullName = cObj.fullName + "." + fieldName + "__c";
cf.label = fieldName.ToString();
cf.type = FieldType.Text;
cf.length = 250;
MetadataService mBinding = new MetadataService();
mBinding.SessionHeaderValue = new basicSample_cs.apexMetadata.SessionHeader();
mBinding.SessionHeaderValue.sessionId = binding.SessionHeaderValue.sessionId;
mBinding.Url = binding.Url.Replace(@"/c/", @"/m/");
AsyncResult asyncResult = mBinding.create(new Metadata[] { cf })[0];
while (asyncResult.state == AsyncRequestState.InProgress)
{
Thread.Sleep(asyncResult.secondsToWait * 1000);
Console.WriteLine("Checking status...\n\tState:" + asyncResult.state + "\n\tStatus: " + asyncResult.statusCode + "\n\tSeconds to wait: " + asyncResult.secondsToWait);
asyncResult = mBinding.checkStatus(new String[] { asyncResult.id })[0];
}
if (asyncResult.state == AsyncRequestState.Completed)
{
Console.Write("Custom field has been created.");
Console.ReadLine();
}
}
catch (Exception ex)
{
Console.WriteLine("\nFailed to create object: \n"
+ ex.Message);
Console.WriteLine("\nHit return to continue...");
Console.ReadLine();
}
}
Guys anyone workaround for the questions posted. Even I am encountering same error
" Must specify 'precision'"
I am having the same problem. Has anyone found a work around?