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
adreameradreamer 

Cannot create a custom field of type integer with the Metadata API

Hi All,

 

Is it possible to create a custom field of type integer in a custom object ?

 

Using the deploy() method with a zipped manifest I use for the custom field the following:

type: Number

 

The issue is that it fails (Metdata API failure) in the following cases:

- if I don't provide the precison

- if don't provide the scale

- if precison is not larger than scale.

 

So the net result is, when I provide precision and scale, it creates a field of type double always.

 

Any help would be much appreciated.

 

Regards,

Fernando

SomeshSomesh

precision and scale are required when creating a field of type Number.

precision is the number of digits and scale is the number of digits after the decimal.

ex. 10.1 has a precision of 3 and scale of 1. 

 

Try setting the scale to 0.

 

hth

 

adreameradreamer

Hi Somesh,

 

Thank you for your reply.

 

What you suggest will generate a field of type Double with no numbers to the right of the decimal point.

 

Reading back what I wrote I think I wasn't clear enough, apologies.

 

What I mean is the following.If you use ant of the describe methods in Apex to get the describe information for an object and its fields, you will see that there fields of type Integer and there fields of type Double. For instance, if you do that for the Opportunity object, you will see that the field FiscalQuarter is of type Integer, and has precision=scale=0.  So what I mean by creating a custom field of type Integer is to be able to create a such a field so that when I retrieve the describe information it will appear as with the FiscalQuarter example -i.e. its type will be Integer, and precision=scale=0.

 

I am begining to suspect that fields such as FiscalQuarter of type Integer and precision=scale=0 are fields internal to salesforce because these type of fields cannot be created with the online interface. There when you create a field of type "Number" it always ends up being of type Double. And you are right, if I set the scale=0 I get something that behaves like an Integer.

 

Regards,

Fernando

dkadordkador

Right, the int fields are salesforce internal ones.  Custom number fields are always type "double", but setting scale to 0 gives you a double that behaves like an int.

adreameradreamer

Hi dkador,

 

Thanks for your reply.

 

Out of curiosity, have you came accross a document/manual where explicitly says that the int types are internal of salesforce ?. I am asking because it took quite an effort to figure that out and it would have been simple to have it documented somewhere.

 

Regards,

Fernando

dkadordkador

No, I doubt this is doc'd anywhere.  I know because I work for salesforce. :)

 

I'll see if I can get this doc'd somewhere for you.

adreameradreamer

That will be fantastic !

 

Thank you.

Mark SFMark SF

Just to close out this thread ... the following doc was added to http://www.salesforce.com/us/developer/docs/api_meta/index_Left.htm#StartTopic=Content/meta_field_types.htm#meta_type_fieldtype

A custom field of type Number is internally represented as a field of type double. Setting the scale of the Number to 0 gives you a double that behaves like an int.

I hope that helps.