ZKSForce更新销售人员对象

时间:2018-01-11 00:08:12

标签: ios swift salesforce

使用ZKSForce SDK时遇到问题。我想更新销售人员的对象。

我找到了在objective-c中更新销售人员对象的方法。 Example Online Here

 ZKSObject *sfobj = [[ZKSObject alloc] initWithType:@"Your_custom_object__c"] ;    

    [sfobj setType:@"Your_custom_object__c"];
    [sfobj setFieldValue:@"a0FM0000000XrKcMAK" field:@"Id"];
    [sfobj setFieldValue:@"PAL-008" field:@"Service_code__c"]; 
    [sfobj setFieldValue:@"Room heating system" field:@"Name"];   //update the field value required
    [sfobj setFieldValue:@"Maintenance" field:@"Service_Status__c"];
    [sfobj setFieldValue:@"a07M0000000FV5VIAW" field:@"child_of_another_custom_object__c"];

     [[FDCServerSwitchboard switchboard] update:[NSArray arrayWithObject:sfobj] target:self selector:@selector(updatedObjectResult:error:context:) context:nil];

但是,我试图在 Swift 4 中执行此操作。在下面的代码中我是如何获得销售人员和检索数据的,但我不知道如何实现上面的objective-c代码来更新数据。

    //Initial Access to Salesforce in order to query data
    client.performLogin(accessUsername, password: accessPassword, fail:{ (fail) in

    }) { (success) in

        let getCasesSQL = "put getcases here"
        self.queryResult = self.client.query(getCasesSQL)

         for o: Any in self.queryResult.records() {

          //How im retrieving an object
          let currentUserID = ((o as AnyObject).fieldValue("Id"))!

}

我尝试模仿Objective-c代码,但我对对象和强制转换非常困惑,试图了解真正发生的事情。

let sfobject = ZKSObject()
 sfobject.setType("Lender__c")
 sfobject.setId(clientData.userID)
 sfobject.setFieldValue("Test" as NSObject, field: "State__c")
 sfobject.fieldValue("State__c")
  print(sfobject)
self.client.update([sfobject])
//Printing Lender__c "userID" fields=(null) toNull=(null)

0 个答案:

没有答案