An explanation and Demo of the SET Action

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

An explanation and Demo of the SET Action

Post by Jaymer »

Objective: To figure out a use of the SET Command

Here are my SET commands: (BO SetLines)
Screen Shot 2019-06-27 at 12.10.59 PM.png
Screen Shot 2019-06-27 at 12.10.59 PM.png (8.92 KiB) Viewed 3220 times
The Process:
Screen Shot 2019-06-27 at 12.11.51 PM.png
Screen Shot 2019-06-27 at 12.11.51 PM.png (11.68 KiB) Viewed 3220 times
And the final result: (BO testobject)
Screen Shot 2019-06-27 at 12.10.46 PM.png
Screen Shot 2019-06-27 at 12.10.46 PM.png (12.89 KiB) Viewed 3220 times
Setup:
testobject already had 5 records in it. what you're seeing is the application of the SetLines commands "applied" to the existing data in testobject. Only specified fields were updated, without a lot of IF statements or complicated parsing.

Discussion:
The original post "Anyone have a cool use..." was asked with no replies. It follows this post for completeness.

The only use I can figure from this is a scenario where a set of fields needs to be updated in a specific record... but you don't know which fields will be supplied. The SET allows for any combination of fields to be supplied in any order.

You can't use an IMPORT because you have to specify the column names in the header line, and in this scenario, each input line doesn't contain values for every field.

If you had a very normalized database, you probably don't need to do it this way, because these data points that are being posted could be in a reference table and if you supplied a key value with the data, you'd just locate that child rec and update. You would just submit a key/value pair and Aware could update it.

the SET works when you have a "wide" data record and need to update a "random" field in that record.
NOT like if you needed to update the Arrival Time on a Flight record - this would be a simple 1-to-1 update... call an Aware routine passing in Flight# and set the ETA. No SET needed.

I envision a REST routine allowing submission of these data strings and then Aware just writes them to a file to be processed (my SetLines BO). Scheduler can check for entries and call the SET subroutine... but I still can't think of a good real-world use.

--> jaymerTip
Last edited by Jaymer on Sun Dec 08, 2019 5:21 pm, edited 13 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
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Anyone have a cool use of the SET Action ?

Post by Jaymer »

the original post:

from the Docs:
The SET action allows setting values of several attributes of a business object from a string. The format of the import string must be one of the following:
...

1) I'm unclear why this immediately follows the IMPORT Action section in the docs. How is it related (if at all)
2) Why the word "import string" is used above (see highlight), because this isn't used ONLY with IMPORT.
3) Seems like nowadays, you could put records into a file any number of ways (doesn't seem like this is directly related to IMPORT) beit an import, or a REST handler waiting for input to modify values... or even another Process.

Personally, I've never found a use for this.
Wondering if anyone has used it and for what reason.

I can imagine taking a string, possibly from an import, like this:
"TripID#1000#PassQty#2#Option1#Main#Option6#Yes"
"TripID#1001#Name#Jaymer#Option1#Main#Option2#1095.99#Option3#
(NOTE: You can see the columns are not the same in each record.)

In this case, you might have many fields in a table, but only want to update specified fields.
A regular IMPORT can't do that because you'd have to specify column names for every column, and if you only provided a value for column 2, then the others would get updated to NULL (i assume) since the default mode of IMPORT is an Update based on the primary key/ID.

You could have a REST routine that accepts strings and just writes them to a file. In this case, the Trip BO. Later, process the strings (shown above) and any specified field will get updated with a value... without a bunch of IF statements to update only the supplied fields.
It DOES seem like a nifty function, given the right use case.

thx
jaymer...



Also,
the Docs say this: "The SET action of the Aware IM Rule Language can be useful for analysing the received e-mail provided that the body of the e-mail is in a format required by the SET action."
I don't see how an email will be formatted with delimiters that allow this to be used?
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
Post Reply