Importing and Error Management?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Importing and Error Management?

Post by PointsWell »

Does anyone have any examples of how to:
  1. Use Failure rules - the user guide is a bit vague. Are there examples in any of the Sample apps? Or does anyone have a test BSV demonstrating how it works?
  2. Have imports fail gracefully - for example if there is a typo in the field headings of a CSV file that is being imported the process collapses in a heap. I'd like to be able to trap the failure and progress to return to later. Also it would be helpful for operator use to not have to debug and rerun everything.
  3. Capture the ImportResults from an import process as per p375 of the user guide

    Code: Select all

    After the import has been finished a special predefined object called ImportResults is placed into the Context. You can use this object to obtain import log and check whether any errors have been detected. This object has the following attributes – ErrorsDetected and Log.
    I have used this to try to populate an import log BO with attibutes ErrorsDetected (which returns "yes" or "No" (literal not binary) but the Log attribute never has any data in it.
  4. Last question, what is the escape character to allow the use of single quotes in my CSV. I have a list of dial codes that is imported and for some reason the cross reference to country CIV - Cote d'Ivoire never finds the appropriate country and with Create if not found it generates a new Country for Cote d'Ivoire even though there is already a record for that. (I have to cross reference against Country and not just ISO3 code because Ceuta and Melilla are ESP but are geographically different
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Importing and Error Management?

Post by BobK »

1) Attached is a bsv that demonstrates failure rules, see below for more details
2) Sorry can not help you
3) I have stopped trying to get that to work, let me know if you have any success.
4) I am not 100% sure this is correct, but try \047


FailureRules.bsv details
This BSV has 2 BOs: UpdatedBO and UpdateData

UpdatedBO has the following attributes: Name, Description, Total and LastUpdate.
It also has 2 rules:
A) if the BO was changed, update the LastUpdate to CURRENT_TIMESTAMP
B) if Total > 10000, REPORT ERROR 'Total Too High'

UpdateData has the following attributes: Name, Number1, Number2, Description and ErrorMessage.
This BO has no rules.

UpdatData has data to be used to update UpdatedBO.

This BSV has several processes
CreateDate => deletes any existing test data and creates new test data

FindUpdateData1 => finds all UpdateData in batches of 1 and calls WithFailureRules

WithFailureRules => basically, it finds the UpdatedBO with the same name as UpdatdData and sets UpdatedBO.Total = Updatedata.Number1 * Updatedata.Number2. If there is no UpdatedBO with the smae name as the UpdateDate, REPORT ERROR 'record not found' is executed.
This process has failure rules that save the error message in the UpdateData.ErrorMessage field and if the error message was 'Total Too High' the UpdatedBO.Total is set to -1.

FindUpdateData2 => just like FindUpdateData2 except executes NoFailureRules after the find.

NoFailureRules => just like WithFailureRules but (surprise) it does not have any failure rules.

To use this BSV:
load it into your Aware system and sign in as admin.

select the menu item "Create Test Data" to create the test data

select the menu item "Run No Failure Rules" to executd FindUpdateData2 and NoFailureRules. The first UpdatedBO will be updated successfully, but you will get an error "Total Too High" for the second UpdateBO and it will not be updated. Also the process will be terminated and the third UpdateData record will not be processed.

select the menu item "Run With Failure Rules" to execute FindUpdateData1 and WithFailureRules. No errors will be displayed, both UpdateBO records will be updated and the last 2 UpdateData records will have the errors saved in the Error Message field.


I do not use failure rules on processes run by users, since I want the user to see the error and let them choose what action to take. But I have multiple processes that run via the scheduler and they all have failure rules so that they run to completion even if there are errors.
Attachments
FailureRules.bsv.zip
(41.42 KiB) Downloaded 523 times
Bob
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Save the ImportResults document after IMPORT Action

Post by Jaymer »

--> Importing a file and saving the ImportResults log file.

Been working for me since v7

BO
Screen Shot 2019-02-06 at 4.07.38 PM.png
Screen Shot 2019-02-06 at 4.07.38 PM.png (34.69 KiB) Viewed 8212 times
Process
Screen Shot 2019-02-06 at 4.06.33 PM.png
Screen Shot 2019-02-06 at 4.06.33 PM.png (11.37 KiB) Viewed 8212 times

DB Recs
Screen Shot 2019-02-06 at 4.04.11 PM.png
Screen Shot 2019-02-06 at 4.04.11 PM.png (50.29 KiB) Viewed 8212 times

--> JaymerTip
Last edited by Jaymer on Thu Oct 24, 2019 7:01 pm, edited 3 times in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Importing and Error Management?

Post by PointsWell »

Jaymer wrote:Been working for me since v7

BO
Screen Shot 2019-02-06 at 4.07.38 PM.png
Process
Screen Shot 2019-02-06 at 4.06.33 PM.png

DB Recs
Screen Shot 2019-02-06 at 4.04.11 PM.png

Thanks Jaymer. Looking at your example I notice that the Log is a Document object. This seems to be a KEY piece of information that is missing from the documentation.

This is a running sore with me, I am fed up being made to feel like a moron for not being able to get something to work because key pieces of information are omitted from the manuals. The exact text from the manual is

Code: Select all

After the import has been finished a special predefined object called ImportResults is placed into the Context. You can use this object to obtain import log and check whether any errors have been detected. This object has the following attributes – ErrorsDetected and Log.
Nowhere int hat text does it define what the attributes should be and there is no other reference to ImportResults anywhere in the manual.

I would HAPPILY forgo an entire upgrade cycle in preference to seeing the documentation fixed, brought fully up to date and available online in a way that the community can comment and add to as a knowledge resource. Otherwise key functionality just looks like it doesn't work, which undermines the work that Vlad et al has done on a pretty cool piece of software.
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Importing and Error Management?

Post by Jaymer »

Then I must self congratulate myself as a genius for figuring it out.
Truth is, there’s no way I could remember how I figure that out. Or if I found an example, or emailed Vladimir. No idea - it was so long ago.

But this is similar to the hours I spent trying to get email working where are each user can have his own email account login and password information.
George just helped on another thread, with the sample bsv that didn’t what is needed.
English is not his native tongue, so I’m going to rewrite it, because it’s extremely handy for everyone to know, and by no means is it documented and obvious.

Again, similarly, Bwalk contacted me recently about executing a curl command.
He was pointing out that he is mostly a python developer. And in python it’s very easy to find library‘s, import them, and just get something to work.
Whereas in his new journey in aware, he’s having to spend time, invent, pay money I think in some cases, to get certain tasks to run.
There is no documentation on how to send an SMS message. Something, that in today’s age, you would think should be a standard part of the software and it’s documentation.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Importing and Error Management?

Post by BobK »

Jaymer wrote:Been working for me since v7

BO
Screen Shot 2019-02-06 at 4.07.38 PM.png
Process
Screen Shot 2019-02-06 at 4.06.33 PM.png

DB Recs
Screen Shot 2019-02-06 at 4.04.11 PM.png
Lucky you. Does not work if using FROM XML
Bob
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Importing and Error Management?

Post by PointsWell »

BobK wrote:1) Attached is a bsv that demonstrates failure rules, see below for more details
....
FailureRules.bsv details
This BSV has 2 BOs: UpdatedBO and UpdateData

UpdatedBO has the following attributes: Name, Description, Total and LastUpdate.
It also has 2 rules:
A) if the BO was changed, update the LastUpdate to CURRENT_TIMESTAMP
B) if Total > 10000, REPORT ERROR 'Total Too High'

UpdateData has the following attributes: Name, Number1, Number2, Description and ErrorMessage.
This BO has no rules.

UpdatData has data to be used to update UpdatedBO.

This BSV has several processes
CreateDate => deletes any existing test data and creates new test data

FindUpdateData1 => finds all UpdateData in batches of 1 and calls WithFailureRules

WithFailureRules => basically, it finds the UpdatedBO with the same name as UpdatdData and sets UpdatedBO.Total = Updatedata.Number1 * Updatedata.Number2. If there is no UpdatedBO with the smae name as the UpdateDate, REPORT ERROR 'record not found' is executed.
This process has failure rules that save the error message in the UpdateData.ErrorMessage field and if the error message was 'Total Too High' the UpdatedBO.Total is set to -1.

FindUpdateData2 => just like FindUpdateData2 except executes NoFailureRules after the find.

NoFailureRules => just like WithFailureRules but (surprise) it does not have any failure rules.

To use this BSV:
load it into your Aware system and sign in as admin.

select the menu item "Create Test Data" to create the test data

select the menu item "Run No Failure Rules" to executd FindUpdateData2 and NoFailureRules. The first UpdatedBO will be updated successfully, but you will get an error "Total Too High" for the second UpdateBO and it will not be updated. Also the process will be terminated and the third UpdateData record will not be processed.

select the menu item "Run With Failure Rules" to execute FindUpdateData1 and WithFailureRules. No errors will be displayed, both UpdateBO records will be updated and the last 2 UpdateData records will have the errors saved in the Error Message field.


I do not use failure rules on processes run by users, since I want the user to see the error and let them choose what action to take. But I have multiple processes that run via the scheduler and they all have failure rules so that they run to completion even if there are errors.
Thanks BobK, I had a look at this and that seems straight forward.
Post Reply