Creating Custom fields from Flex (Salesforce)
I'm trying to CREATE custom fields from flex, but I'm having hard time finding the correct syntax.
Below is the piece of code that I'm using and it's resulting in error "sf:INVALID_TYPE INVALID_TYPE: null objects not allowed in create/update request"
var con:Connection = new Connection();
var lRequest:LoginRequest = new LoginRequest();
lRequest.username = username1.text;
lRequest.password = password1.text;
lRequest.callback = new mx.rpc.Responder(createFields, loginFault);
con.login(lRequest);
//CreateFields Method ....
v开发者_StackOverflow社区ar externalIdField:CustomField = new CustomField();
externalIdField.label = 'ProductionId';
externalIdField.type = FieldType.ID;
externalIdField._length = 18;
externalIdField.externalId = true;
externalIdField.unique = true;
var customObjectVar:CustomObject = new CustomObject();
customObjectVar["type"] = "Account";
customObjectVar.addField(externalIdField);
var objarray:Array = [];
objarray[0]=customObjectVar;
con.updateObject(objarray,new mx.rpc.Responder(saveresults,sfdcFailure));
Tried below alternate way (as suggested by Simon), that too results in error
"soapenv:Client Element {http://soap.sforce.com/2006/04/metadata}type invalid at this location"
var externalIdField:CustomField = new CustomField();
externalIdField.fullName = 'Account.ProductionId__c';
externalIdField.type = FieldType.STRING;
externalIdField._length = 18;
externalIdField.externalId = true;
externalIdField.unique = true;
var objarray:Array = [];
objarray[0]=externalIdField;
con.updateObject(objarray,new mx.rpc.Responder(saveresults,sfdcFailure));
`
To create fields you would pass a CustomField instance to the metadata api create call (its not clear from your code what con
is), in addition to the fields you've set, you need to set the fullName (e.g. Account.ProductionId__c in this case)
精彩评论