Remember to change to the correct field before proceeding to run ANY script.
SELECT TOP (10)
AccNo,
CompanyName,
Address1,
Address2,
Address3,
Address4,
Phone1,
DisplayTerm,
EmailAddress,
SalesAgent,
LastModified
FROM Debtor
WHERE LastModified > "{LAST_MODIFIED_DATE_TIME}";
In order to sync, you must include LastModified
in SELECT
"SQLSync": [
{
"name": "AutoCount to Inistate",
"enabled": false,
"connectionString": "Data Source={SERVER};Initial Catalog={DATABASE};User Id={DB_USERNAME};Password={DB_PASSWORD};",
"hook": "https://api.inistate.com/api/automationHook/hook/{MODULE-ID}-{LOGIC-NAME}",
"sql": "SELECT AccNo, CompanyName, Address1, Address2, Address3, Address4, Phone1, DisplayTerm, EmailAddress, SalesAgent, LastModified \nFROM Debtor \nWHERE LastModified > @date",
"lastSync": "{LAST-SYNC-DATE-TIME}",
"start": null
}
]
# debug('test', inputs)
debug("test")
moduleName = "{YOUR-MODULE-NAME}"
inistateKeyField = "DocumentId"
keyField = "Doc"
modifiedDateField = "LastModified"
fields = [["DocumentId", "Doc"], ["LastModified", "LastModified"]]
inistateFields = []
result = list(inputs["list"]).ToList()
for item in result:
entry = Module(moduleName).find({"Dynamic.Extension.{fieldName}": item["AccNo"]})
form = Module(moduleName).execute("sync", entry)
form["{CODE}"] = item["AccNo"]
form["{COMPANY_NAME}"] = item["CompanyName"]
form["{ADDRESS_1}"] = item["Address1"]
form["{ADDRESS_2}"] = item["Address2"]
form["{ADDRESS_3}"] = item["Address3"]
form["{ADDRESS_4}"] = item["Address4"]
form["{PHONE_NO}"] = item["Phone1"]
form["{CREDITS_TERM}"] = item["DisplayTerm"]
form["{EMAIL_ADDRESS}"] = item["EmailAddress"]
form["{AGENT}"] = item["SalesAgent"]
debug("form", form)
Module(moduleName).submit(entry, form)