cancel
Showing results for 
Search instead for 
Did you mean: 

Access value from previous transaction action step

agentry_src
Active Contributor
0 Kudos

[Migrated from the Syclo Resource Center]

gary.mayes   01/06/2012 12:33,

Hi,I have an Action with two Transaction action steps - both Complex Table Change transactions.Is it possible to access one of the values from the 1st action step from the 2nd one?I.e. if the first one had a property called Customer, can I access this Customer value from the second action step?I can't seem to figure out a way in the property browser to do this that works...

  Previously I'd got round this by picking up the last object in a collection (as that was the most recently applied one) but don't think this would give me the same result when working with complex tables.I feel there must be a way of picking up a value from the previous step, as it's all still in the context of the same Action, just a different Step.Can anyone offer any advice on this?

Thanks!Gary

Jason Latko   01/09/2012 11:47

Gary,I would suggest just doing a Complex Table lookup in the second transaction to look up the values you want from the already applied first transaction, using the COMPLEXTABLE rule function found in the TABLE function group.

  You might also be able to target the first transaction using the "Other Transactions" group in the property browser, but I'm not sure if that would work.

  Easiest no hassle way is to apply the first CT transaction and then just look up the row again in the second transaction using the COMPLEXTABLE function.

Jason Latko - Senior Product Developer at Syclo

gary.mayes   01/11/2012 12:02

Hi Jason,Thanks for the info. The slight problem I had was that the first transaction was the one where the unique_id was generated, so unless I could see the ID that was generated, I couldn't look it up in the second one.I also couldn't seem to get the values by targeting the transaction via "Other Transactions" when they were 2 separate steps.Targetting using "Other Transactions" DID work however when I made the 2nd one a "SubAction to run when the transaction is completed", in the Action Step Definition page. It seems it can work out the current context that way.

Thanks for the pointers!

Gary

Jason Latko   01/11/2012 14:38

Gary,Glad you got it going.

  I forgot to mention the "SubAction to run when the transaction is completed" option.

  You mentioned not having your key available in the second transaction since it was generated in the first one.

  I often get around that by writing the key back to a static main object property called "TempKey" or something like that from the 1st transaction and use that to reference in the second one.

  Your first complex table transaction can additionally target this main object temp property and update it, as well as modifying/adding the complex table row.

  Although a transaction is set up to point to a particular object type, you can target properties in other objects by using the object browser to point somewhere else.

  Just something to keep in mind for the future.

Jason Latko - Senior Product Developer at Syclo

gary.mayes   01/12/2012 11:34

Hi Jason,Very glad you mentioned the TempKey idea - as I found today for a different action, it wasn't even working when using the "SubAction to run...." method - possibly due to them targetting different objects but have given up trying to work out why now.Storing the key under the main object as a property is working very well for what I needed to achive, and definitely not something I would have thought of! Great to know these types of hints/tips and why I find the forum so helpful for these "off-manual" solutions!

Thanks again!Gary

Jason Latko   01/12/2012 12:24

Gary,I have found that  "SubAction to run...." can be quirky in some cases also and like you, I gave up trying to debug the problem.

  I have personally abandoned it as an option, preferring the TempKey variable method.

  It has never failed me!

  "Off-manual" is my middle name around here - LOL.Jason Latko - Senior Product Developer at Syclo

Accepted Solutions (0)

Answers (1)

Answers (1)

Marçal_Oliveras
Active Contributor
0 Kudos

Hi Jason,

I arrived here from my previous thread about performance.

Now I pre-built the data, but when a CATSRecord object is created/edited/deleted I should add or subtract minutes from the total amount stored in a different object CATSHeader.

I tried to do your work around, I created a new field to the CATRecord Add transaction. This new field is pointing to the CATHeader object selecting from the collection by key field (which is CATSRecord work date).

But I test this I get the following error: Cannot Validate Transaction - CATSRecordAdd Transaction property 100 missing target (:>Main Object>" Property>(U|"WorkDate" Property)>"Z_TotalMinutesPerno" Property)

Is it possible that this work around is not possible in newer versions since this post is from 2012? Or maybe I didn't understand you and it's not possible to modify a different object type than the one specified in the transaction.

How can I manage to know which CATSRecord has been added/edited/deleted, the date and how many minutes where added or subtracted if this way is not working?

jason_latko
Advisor
Advisor
0 Kudos

Marcal,

That should be working.  In the Property Browser,  don't use "MainObject", use "Whatever module's Main Object" as your start point to find the parent object.  I believe there is an existing bug where finding a record by key will not work if you go the "MainObject" node route.  Try that first.  Also, how did you reference the current CATSRecord's date property?

A colleague of mine found a current editor bug when trying to target an object in a sub-action using "First object where rule is true".  The current editor is broken in that case, so we had to create the sub-action in an older editor and import the definition into the new one.

Jason Latko - Senior Product Developer at SAP

Marçal_Oliveras
Active Contributor
0 Kudos

Hi Jason,

I'm not sure if I understand your tips. To select the CATSHeader I do the following I don't see any other way (well I tried to go via Main Screen Set -> Displayed MainObject too):

When I have to select the Key Field, another menu is opened and I select the WorkDate from the CATSRecord object (the one that is being created in the Add transaction). I also tried to select the WorkDate going to "Other Transactions" and select the field of my actual transaction, but it didn't work as well.

Marçal_Oliveras
Active Contributor
0 Kudos

I tried to test the scenario in the ATE and it works there. So the problem modifying the other object only happens in the iPad and it's due the selection of the CATSHeader because if instead of selecting by key I just select the First object in the collection, it works fine even in iPad

I thought that the reason was the date format since in the ATE is mm/dd/yyyy and in the iPad dd/mm/yyyy, but I changed the device region to U.S. to have the same format and I still have the same problem.

I also created a popup to see if the dates are stored different in the objects, but it's not the case.

Any ideas?

jason_latko
Advisor
Advisor
0 Kudos

Marcal,

Since you are having a problem using the "Key" syntax on iPad which was the fastest and correct approach, instead use the "First object where rule is True" technique.  The same way you selected "First Object" in the collection, instead choose by rule.  The rule should return true when the row is found, and will loop over the collection once for each row until it finds a match.  So in your case, use EQNUM to compare the WorkDate fields on the CATSHeader object against the current WorkDate property from the transaction.  Let me know if this works for you and we may need to file a platform bug about "Key" suntax not working on iPad.

Jason Latko - Senior Product Developer at SAP

Marçal_Oliveras
Active Contributor
0 Kudos

Hi Jason,

Unfortunately the problem is not due the selection by "Key" way to get the CATSHeader.

I proofed it because when I'm printing each CATSRecord details in the list view, I added a new field called CATSHeaderWorkDate that is selecting the date using the same technique.

But to be sure, I followed your tip and created a rule that is returning true when the CATSHeader work date is the same than the CATSRecord object transaction work date and it fails as well...

I'm not sure what else can I try...

Edit: In the rule I tried 2 different things, I hardcoded the CATSRecord date instead of reading it from the transaction object and then it's working. What I did too is compare the CATSHeader date with the current date using DATE function. Both cases work, so it's not a problem with date formats, the issue is retrieving the WorkDate field from the CATSRecord to search the related CATSHeader.

jason_latko
Advisor
Advisor
0 Kudos

Marcal,

How have you tried to retrieve the WorkDate from the current transaction in your search rule?  What syntax have you tried?  This should work without a problem for you.

Jason Latko - Senior Product Developer at SAP

Marçal_Oliveras
Active Contributor
0 Kudos

Hi Jason,

I tried many different ways. For example going to the transaction like this:

Then also I tried to get the field from the current screen, and from the current CATSRecord object, non of them worked. I tried with EQSTR and EQNUM with no results as well.

As I said, if I replace the 2nd parameter by a constant screen like "15/04/2014" or by the function DATE it works fine and the correct CATSHeader is selected, so the EQSTR is not the problem.

jason_latko
Advisor
Advisor
0 Kudos

Marcal,

Try it like this and let me know if it works for you:

EQSTR

     CATSHeader Object -> Workdate property

     Workdate property

Jason Latko - Senior Product Developer at SAP

Marçal_Oliveras
Active Contributor
0 Kudos

Hi Jason, sorry to keep bothering with the issue, but I think is not possible to do as you say.

If I create a rule to select The First "CATSHeader" Object in the collection where the XXX rule is true, the rule context is adjusted in a way that the properties you can select are the ones from the CATSHeader even that we are in the CATSRecord transaction.

What I mean is that the standalone Workdate property will be the property from the CATSHeader and not from the CATSRecord as you assumed.

Here a screenshot on how I created the rule:

jason_latko
Advisor
Advisor
0 Kudos

Marcal,

I understand the context difficulty.  Agentry really doesn't care though where you picked the property from if the name matches, so if the Workdate properties are named the same in both objects, it will assume the current transaction when you just use: Workdate Property, even if you selected it using the CATSHeader context.  Since you fully qualified the first object name, it will look for another object or property with the name Workdate to compare to.  Try it:

EQSTR

     CATSHeader Object -> Workdate property

     Workdate property

If still a problem, try this:

EQSTR

     CATSHeader Object -> Workdate property

     CURRENTVALUE

          "Workdate" (This is a constant and should pull the current transaction property)

or

EQSTR

     CATSHeader Object -> Workdate property

     Current Transaction -> Workdate property

Jason Latko - Senior Product Developer at SAP

Marçal_Oliveras
Active Contributor
0 Kudos

Hi Jason, I didn't update the thread because unfortunately it's still not working and I don't know what else to try.

If I use your last tips CURRENTVALUE or just the workdate, it's returning the 1st CATSHeader, because the retrieved workdate is not from the CATSRecord object but from the CATSHeader that the rule is looping.

I don't have the option to select the Current Transaction -> Workdate, but what I did is go to Other Transactions -> Select the specific transaction -> Workdate (Current value). And still it's not working, the work date comes empty. It happens the same if I select the Screen Set -> Workdate field -> Current Value.

jason_latko
Advisor
Advisor
0 Kudos

Marcal,

When does the Workdate of the child transaction get set?  Screen field, or initial value from rule?  I am thinking that the CATSHeader targeting is trying to take place before the child Workdate is even set, explaining why it is always blank.

At this point, I think the way you should handle this is to add a 2nd transaction that edits the CATSHeader rather than trying to do it in the same child transaction.  Target the CATSHeader using the same style in a new Transaction step in the same action after adding or editing the child object: Main Object -> CATSHeader Collection -> First Object Where Rule SearchCATSHeader is True

Then SearchCATSHeader is:

EQSTR

     CATSHeader Object -> Workdate property

     Main Object -> Child Collection -> Last Object -> Workdate property

Or

EQSTR

     CATSHeader Object -> Workdate property

     Child Object -> Workdate property

The above depends on whether you added or edited the child object first.  If you added, you can get at it using Last Object, if you edited, the context in the 2nd rule will work as long as this Action was passed the Child object for editing.

Lastly, set the CATSHeader properties using: Initial Value: From other object:

Either style below again depending on whether the child was added or edited:

Child Object -> Whatever property

Main Object -> Child Collection -> Last Object -> Whatever property

Jason Latko - Senior Product Developer at SAP

Marçal_Oliveras
Active Contributor
0 Kudos

Hi Jason,

Finally what I did is create a global property on the main object to store the date before the Add time record transaction.

I disabled the field where the user can change the date during the creation and they will be able to add time for the currently selected date on the CATSHeader listview and then tap the create time button.

The edit is working properly in the way you explained since the beginning, so the date from the transaction can be retrieved.

Finally, it seems that a delete transaction doesn't allow to modify any other object attribute even when I have the date, so previous to the delete a time record I had to add an edit CATSHeader transaction that subtracts the time of the currently selected time record to the CATSHeader total.

Since we also have crew manager I have another field with the total worked time for the crew, I had to do a lot of modifications, new properties and transactions just to keep the CATSHeader updated. Not very nice but at least it works.

Thank you for your help, it has been very useful.