I have an if statement that is iterating through json data successfully but for some reason my if statement always reads as true when that shouldn't be the case. The result of this is the rest of my if statement isn't carried out so the data that I need to go to other fields is being reinserted in the same field rather than progressing to the next one.
Here is my code.
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 ]
The script works but why is my if statement reading as true?
Aucun commentaire:
Enregistrer un commentaire