Hi from a Newbie!
I have a patient details database and a consultation database. How can I update the consultation database with the changes made to the patient detials database? Maybe in a scheduled Agent?
I have tried using getdocumentbykey, tested it on a single one, but when I compare the field values, I get errors, one of which is “Type mismatch”, but how would I check all the documents in the consulation database and only changes those documents and those fields that have changed in the patient’s database?
Ta
Subject: Getdocumentbykey the right way?
Type Mismatch error comes may be when you are comparing number with text or vice versa. Check the type of 2 values you are comparing.
Easiest way to update your consulatation db would be - Have one unid stored in documents in both the databases. Now take collection of all documents from patient database. Loop them through. For each doc, take a UNId, and using it as a key, get the same document from Consultation document and just do copy all items to consultation document.
Using this, you don’t need to check each item and compare values.
Subject: Getdocumentbykey the right way?
A scheduled agent would work, but you’d probably find that code running in the PostSave event of a form would be more satisfactory. It depends, really, on the permissions required – a scheduled agent can work with much higher permissions than a given user has, so it may be a more appropriate solution (especially in a medical environment).
For any real help on the type mismatch errors, though, we’d need to see your code. There are any number of possible reasons for a type mismatch, from attempting to compare an array to a scalar value, to forgetting to allow for the fact that an empty Notes item (field) will contain a single-value array containing an empty string no matter what the field settings on the form are.