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
FredrickUNFredrickUN 

Can not specify 'precision' for a CustomField of type Text

Hi,
 
Im trying to create a TEXT field on a custom object using the metaData API.
 
It keeps failing stating that im trying to specify precision for a text field but I'm not.
 
Can anybody help?
 
Here is my code
 

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();

}

}

TeaJayTeaJay

Guys anyone workaround for the questions posted. Even I am encountering same error

" Must specify 'precision'"

GstarkeyGstarkey

I am having the same problem. Has anyone found a work around?