AnsweredAssumed Answered

Scripting Find/Adding Record using Error 401 / Criteria

Question asked by kraftfm on Apr 2, 2013
Latest reply on Apr 4, 2013 by mikebeargie

I am trying to build an add record script into an application. Depending on certain criteria, the user wants to set a different 'date' on the record.

  1. Set date = current date 'if' no records exist for that client-consultation combination
  2. Set date = last date entered for that client-consultation 'if' records exist for this client's consultation


The application is for an alternative medicine counselor and she is entering medication during a consultation for a specific client. A client can have many consultations and can be prescribed many medications. Therefore, in the case where the client 'has' a consult(s), the date to be used is for the 'current' consultation, not others (the add is being done in a portal within a consultation layout).


The table graph is below. The pharmacy table is just used to store medication names.


Screen Shot 2013-03-15 at 3.46.06 PM.png


The 'date' is when an 'Add Record' is requested for a medication to be added to a specific client's consultation. I have written the following script, however am not getting the desired result. (note: fields preceeded with 'x' are Global fields)


Set Field [Consult::xglobalConsultID; Consult::__pkCOnsultID]

Go to Layout ["Medication_Form" (Medication)]

Set Error Capture [On]

Enter Find Mode [Pause]

Set Field [Medication::_fkConsultID; Consult::xglobalConsultID]

Perform Find []

If [Get(lastError)=401]

New Record/Request

Set Field [Medication::_fkConsultID; Consult::xglobalConsultID]

Set Field [Medication::DateStart; Get(CurrentDate)]


Sort Records by Field [Ascending; Medication::DateStart]

Go to Record/Request/Page (Last)

Set Field [Medication::xDate; Medication::DateStart]

New Record/Request

Set Field [Medication::_fkConsultID; Consult::xglobalConsultID]

Set Field [Medication::DateStart; Medication::xdate]

End If

Go to Layout ["Consult" (Consult)]

Go to Object [Object Nate: "Medication Detail Portal"]

Go to Portal Row [Select; First]

Go to Field [Medication::DateStart]


Appreciate some input. THANK YOU!!