创建Salesforce自定义公式字段 - (错误参数类型错误)

时间:2018-01-04 06:32:13

标签: salesforce formulas salesforce-communities

我正在为佣金字段创建一个公式,根据标准进行多次计算。我目前收到的错误是(错误:函数'AND()'的参数类型不正确。预期的布尔值,收到的数字)。我该如何修改公式来解决这个问题?

IF(AND(Order__r.New_Amount_Outstanding__c = 0,Order__r.RecordTypeId =“Bespoke Item”,ISPICKVAL(Payment_type _c,'Deposit'),Date__c> = DATE(2017,04,01)),(Order__r.Amount_RollUp__c) * 1.2 / 100,IF(AND(Order__r.RecordTypeId =“Bespoke Item”,ISPICKVAL(Payment_type _c,'Deposit'),Date__c< DATE(2017,04,01),(Order__r.New_New_Net__c)* 1.2 / 100), IF(Order__r.RecordTypeId<>“Bespoke Item”,(Order__r.New_New_Net__c * 1.2 / 100),NULL)))

它基本上由3个场景组成:

IF(AND(Order__r.New_Amount_Outstanding__c = 0,Order__r.RecordTypeId =“Bespoke Item”,ISPICKVAL(Payment_type _c,'Deposit'),Date__c> = DATE(2017,04,01)),(Order__r.Amount_RollUp__c) * 1.2 / 100,

IF(AND(Order__r.RecordTypeId =“Bespoke Item”,ISPICKVAL(Payment_type _c,'Deposit'),Date__c< DATE(2017,04,01),(Order__r.New_New_Net__c)* 1.2 / 100),

IF(Order__r.RecordTypeId<>“Bespoke Item”,(Order__r.New_New_Net__c * 1.2 / 100),

NULL)))

1 个答案:

答案 0 :(得分:1)

你有一个错位的“)”。当你缩进公式时,很明显:

IF(
  AND(
    Order__r.New_Amount_Outstanding__c = 0,
    Order__r.RecordTypeId="Bespoke Item",
    ISPICKVAL( Payment_type__c , 'Deposit'), 
    Date__c >= DATE(2017,04,01)
  ),
  (Order__r.Amount_RollUp__c) *1.2/100,
  IF(
    AND(
      Order__r.RecordTypeId="Bespoke Item",
      ISPICKVAL( Payment_type__c , 'Deposit'), 
      Date__c < DATE(2017,04,01),
      (Order__r.New_New_Net__c) *1.2/100),
      IF(Order__r.RecordTypeId<>"Bespoke Item",
        (Order__r.New_New_Net__*1.2/100), 
        NULL
      )
   )
)

应该是:

IF(
  /*Test this Argument*/
  AND(
    Order__r.New_Amount_Outstanding__c = 0,
    Order__r.RecordTypeId="Bespoke Item",
    ISPICKVAL( Payment_type__c , 'Deposit'), 
    Date__c >= DATE(2017,04,01)
  ),
  /* If True */
  (Order__r.Amount_RollUp__c) *1.2/100,
  /* If False */
  IF(
    /* Test this Argument */
    AND(
      Order__r.RecordTypeId="Bespoke Item",
      ISPICKVAL( Payment_type__c , 'Deposit'), 
      Date__c < DATE(2017,04,01)
    ),
    /* If True */
    (Order__r.New_New_Net__c) *1.2/100),
    /* If False*/
    IF(
       /* Test this Argument */
       Order__r.RecordTypeId<>"Bespoke Item",
       /* If True */
       (Order__r.New_New_Net__*1.2/100), 
       /* If False */
       NULL
    )
  )
)

Order__r.RecordTypeId =“Bespoke Item”也会评估为TRUE吗?我认为这将是一个Id。