Filemaker如果语句不起作用

Dskip1199

我有一个if语句,它成功地遍历了json数据,但是由于某种原因,在这种情况下,我的if语句总是读为true。这样的结果是我的if语句的其余部分未执行,因此我需要转到其他字段的数据被重新插入同一字段中,而不是前进到下一个字段。

这是我的代码。

Set Variable [ $dataCount; Value:ValueCount ( JSONListKeys ( $json ; "data" ) ) ]
Set Variable [ $i; Value:0 ]
#needs if statement to revert changes if existing
Go to Layout [ “grievances” (grievances) ]
New Record/Request
Set Field [ grievances::_IDgrievance; JSONGetElement ( $json ; "id" ) ]
Set Field [ grievances::grievanceTimestampSubmitted; JSONGetElement ( $json ; "timestamp" ) ]
Loop
#match institution
Set Error Capture [ On ]
If [ (JSONGetElement ( $json ; GetAsNumber ( "data[" & $i & "].field") ) = GetField ( jsonFieldIDs::institution )) ]
Set Field [ grievances::institution; JSONGetElement ( $json ; "data[" & $i & "].value" ) ]
#match delegate
Else If [ (JSONGetElement ( $json ; GetAsNumber ( "data[" & $i & "].field" )) = GetAsNumber (jsonFieldIDs::delegates)) = 1 ]
Set Field [ grievances::delegate; JSONGetElement ( $json ; "data[" & $i & "].value" ) ]
#match grievancedateorignated
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::dateGrievanceOriginated ]
Set Field [ grievances::dateGrievanceOriginated; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match grievanceStep
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::grievanceStep ]
Set Field [ grievances::grievanceStep; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match relatedgrievanceID
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::grievanceSubmissionID ]
Set Field [ grievances::relatedGrievance; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match EmployeesName
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::employeesName ]
Set Field [ grievances::rawEmployeeName; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match EmployeesPhoneNumber
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::employeePhone ]
Set Field [ grievances::rawEmployeePhoneNumber; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match EmployeesAddress
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::employeesAddress ]
Set Field [ grievances::rawEmployeeAddress; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match EmployeesEmail
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::email ]
Set Field [ grievances::employeesEmail; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match EmployeesJobTitle
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::delegates ]
Set Field [ grievances::employeesJobTitle; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match EmployeesShift
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::shift ]
Set Field [ grievances::employeesShift; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match EmployeesSeniorityDate
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::seniorityDate ]
Set Field [ grievances::employeesSeniorityDate; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match Employee Department
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::department ]
Set Field [ grievances::employeesDepartment; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match EmployeesSignature
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::employeeSignature ]
Set Field [ grievances::employeesSignature; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match nature of grievance
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::natureOfGrievance ]
Set Field [ grievances::grievanceNature; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match violation of Article
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::violationOfArticle ]
Set Field [ grievances::grievanceArticle; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match grievanceSection
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::section ]
Set Field [ grievances::grievanceSection; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match grievance Statement of Case
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::statementOfCase ]
Set Field [ grievances::grievanceCaseStatement; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match grievance Adjustment Requested
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::adjustmentRequested ]
Set Field [ grievances::grievanceAdjustmentRequested; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
#match Union Rep or Delegate Signature
Else If [ JSONGetElement ( $json ; "data[" & $i & "].field" ) = jsonFieldIDs::unionDelegateUnionRepSignature ]
Set Field [ grievances::grievanceUnionRepSignature; JSONGetElement ( $json ; "data[" & $i & "]value" ) ]
End If
Set Variable [ $i; Value:$i + 1 ]
Exit Loop If [ $i ≥ $dataCount ]
End Loop
Commit Records/Requests [ No dialog ]
Go to Layout [ original layout ]

该脚本有效,但是为什么我的if语句读为true?

更新

我已经附上了json

{
  "id": "383694318",
  "timestamp": "2018",
  "user_agent": "Mozilla/5.0",
  "remote_addr": "",
  "payment_status": "",
  "form": "",
  "latitude": "",
  "longitude": "",
  "data": [
    {
      "field": "59492998",
      "value": "institution name"
    },
    {
      "field": "61085927",
      "value": "delegate name"
    },
    {
      "field": "59493162",
      "value": "Jan 02, 2016"
    },
    {
      "field": "60868658",
      "value": "1"
    },
    {
      "field": "59493345",
      "value": "first = jane\nmiddle = a\nlast = doe"
    },
    {
      "field": "59493496",
      "value": "555-555-5555"
    },
    {
      "field": "59493502",
      "value": "[email protected]"
    },
    {
      "field": "59493355",
      "value": "CNA"
    },
    {
      "field": "59493364",
      "value": "1st Shift"
    },
    {
      "field": "59493381",
      "value": "Dec xx, 19xx"
    },
    {
      "field": "59493506",
      "value": "https://s3.amazonaws.com/files.formstack.com/uploads/.png"
    },
    {
      "field": "59493533",
      "value": "wrongful termination"
    },
    {
      "field": "59493536",
      "value": "33-1"
    },
    {
      "field": "59493577",
      "value": "XIII"
    },
    {
      "field": "59493589",
      "value": "Wrongful Termination "
    },
    {
      "field": "59493591",
      "value": "make whole"
    },
    {
      "field": "59493713",
      "value": "https://s3.amazonaws.com/files.formstack.com/uploads/.png"
    }
  ],
  "pretty_field_id": "59493345"
}
杰森·夏普(Jason Sharp)

如果jsonFieldIDs::institution返回一个字段名称,GetField()将返回该字段的内容,而不是名称。

如果没有文件/ json进行审核,则很难进行故障排除。

另外,请尝试关闭错误捕获功能,看看是否有任何错误。

更新

在第一个if语句中,您正在json键上使用GetAsNumber,而不是结果:

如果[(JSONGetElement($ json; GetAsNumber(“ data [”&$ i&“] .field”))= GetField(jsonFieldIDs :: institution))]]

应该在外面 JSONGetElement

如果[(GetAsNumber(JSONGetElement($ json;“ data [”&$ i&“] .field”))= GetField(jsonFieldIDs :: institution))]]

另外,GetField由于您直接传递字段,因此我将删除

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章