IMSMA3 script writing
Jump to navigation
Jump to search
| Changes to scripts in 6.0 are outlined in IMSMA3 script changes 6.0. In the Data Dictionary you will find the target field names that should be used in the scripts in the column Pojo name. We also have more documentation than provided in C:\IMSMAng\migration\doc, training material from several GICHD IM trainings and the one script training provided in Afghanistan. |
Approval information is not set
The approval function was changed in 5.08.02 and Approved by and Approved date needs to be set in the script in Pojo Fieldreport.
Attribute.SetDate("ReportVerifiedDate", Data.CurrentDate());
Attribute.SetString("VerifiedBy", "migration");
The different dates in the table fieldreport are explained here.
ID number gets decimals
Especially when using Excel as indata it is common that item ID becomes e.g. Assistance-10.0 which is fixed with 2 Cast.
Attribute.SetString("LocalId", "Assistance-" & Cast.String(Cast.Int(Row.GetAttribute("ID"))));
Limitations
Unfortunately it is still not possible to use the following in scripts:
- greater than (>)
- less than (<)
- LIKE (e.g. Eriks* or Eriks%)
Approval functions
| Function | Generation | wiki reference | Comment |
|---|---|---|---|
| ApproveAsCombine | 5.x | Reconcile started from Data Entry Menu | |
| ApproveAsDelete | 6.0 | Delete from the Summary Window | |
| ApproveAsEdit | 6.0 | Update from Summary Window | Not suitable for scripts if you will not update all fields of the item |
| ApproveAsNew | 5.x | Reconcile as New | |
| ApproveAsReplace | 5.x | Reconcile started from Data Entry Menu | |
| ApproveAsUpdate | 5.x | Reconcile started from Data Entry Menu | Combine or Replace depending on parameter |
| ApproveAsUpdateBase | ??? | ||
| ApproveLocationAsNew | 6.0 | Location | |
| ReconcileAsDelete | 6.0 | Same as above but DEF will be found in the Workbench | |
| ReconcileAsEdit | 6.0 | Same as above but DEF will be found in the Workbench | Not suitable for scripts if you will not update all fields of the item |
| ReconcileAsNew | 5.x | Same as above but DEF will be found in the Workbench | |
| ReconcileAsUpdate | 5.x | Same as above but DEF will be found in the Workbench | Combine or Replace depending on parameter |
| ReconcileAsUpdateBase | ??? | ||
| ReconcileLocationAsNew | 6.0 | Same as above but will be found in the Workbench |
Do NOT use:
- ApproveAndLinkVictim
- this function is super old and the link between Accident/Victim is nowadays done link the other items via the table Link
- ApproveHazardReductionAsProgress
- if the country really want to combine the Progress reports with the Clearance report then I would use Combine.
Data types
- Boolean
- Attribute.SetBoolean("Active", Cast.Boolean("true"))
- Attribute.SetBoolean("Active", Cast.Boolean("1"))
- Date
- Attribute.SetDate("DateOfReport", Cast.Date(Row.GetAttribute("clnEntryDate")))
- Attribute.SetDate("ReportVerifiedDate", Data.CurrentDate())
- Decimal
- Attribute.SetDecimal("AreaSize", Cast.Decimal(Row.GetAttribute("Area Cleared")))
- Double/Float
- Attribute.SetDouble("Latitude", Cast.Double(Row.GetAttribute("clnLatitude")))
- Integer
- Attribute.SetInt("Number", 1)
- Attribute.SetInt("NumberOfDependentsAge0To18", Cast.Int(Row.GetAttribute("clnCA_UserDefined1")))
- Multi-select
- Attribute.AddToSet("HazreducMethods", Pojo.GetImsmaenumByCategory("Clearance Operation", "Manual"))
- Attribute.AddToSet("Vegetations", Pojo.GetImsmaenumByCategory("Vegetation", Row.GetString("clnVegetationTC")))
- Ordnance
- Attribute.SetObject("Ordnance", Pojo.GetPojoByGuid("Ordnance", Row.GetString("clnDeviceSelectedGUID")))
- Attribute.SetObject("Ordnance", Pojo.GetPojoByGuid("Ordnance", "{00000020-0000-0000-0000-000000000000}"))
- Organisation
- Attribute.SetObject("Organisation", Pojo.GetPojoByGuid("Organisation", Translate.toDbLookup("org_guid", "organisation", "org_guid", Cast.String(Row.GetAttribute("clnOrganisationGUID")))))
- Place
- Attribute.SetObject("Medicalfacilitylevel3", Pojo.GetPojoByGuid("Place", Row.GetString("clnMedicalLevel3GUID")))
- Single-select
- Attribute.SetObject("VegetationDensity", Pojo.GetImsmaenumByCategory("Density", "Not Specified"))
- Attribute.SetObject("OccupationAfterEvent", Pojo.GetImsmaenumByCategory("Occupation", Row.GetString("clnCA_UserDefined13")))
- String
- Attribute.SetString("Bestroutetohazard", Row.GetString("clnRouteToSite"))
- Time (which is kind of a date)
- Attribute.SetDate("TimeToHospital", Cast.Date("2015-10-10 " & Translate.toDbLookupSQL( " SELECT to_char( (( \"tblIncAccCasualty\".\"clnTimeToHospital\" * 60) || 'minute')::interval, 'HH24:MI:SS') FROM \"tblIncAccCasualty\" WHERE \"clnGUID\" = ?", Row.GetString("clnGUID") ) ))
- Timestamp
- Attribute.SetDate("StartDate", Cast.Date(Cast.String(Row.GetString("Start of Reporting Period"))& " 14:00:00"))