从 Flex (Salesforce) 创建自定义字段

发布于 2024-11-11 16:29:23 字数 1587 浏览 3 评论 0原文

我正在尝试从 Flex 创建自定义字段,但我很难找到正确的语法。

下面是我正在使用的代码片段,它导致错误“sf:INVALID_TYPE INVALID_TYPE:创建/更新请求中不允许空对象

    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 ....
    var 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));

尝试了以下替代方法(按照西蒙的建议),这也会导致错误

“soapenv:客户端元素 {http://soap.sforce.com/2006/04/metadata}类型 在此位置无效”

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

`

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 ....
    var 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));

`

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷情 2024-11-18 16:29:23

要创建字段,您需要将 CustomField 实例传递给元数据 api create 调用(从您的代码中不清楚 con 是什么),除了您设置的字段之外,您还需要设置 fullName (例如本例中的 Account.ProductionId__c )

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文