Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


ddtisysadmin
2017-09-06T17:06:43Z
I am trying to set up a child job that is run from a parent job. The variables are set only in the parent job, then when it's triggered, I want it to pass those variables to the child job. I've had to pass each variable individually, rather than just inheriting job variables from the parent, but this seems to work.

The problem is, the variables in the child job are being permanently defined, which confuses things greatly. I've tried adding a "Remove Variable" task, which only seems to work on user variables. Even if I could use that, I have something like 60 job variables which are being calculated/passed/defined throughout the child job, so I would need to add that many steps to remove each one individually.

I have seen at least two other feature requests from years ago, but I have not figured out a way to remove variables by wildcard. In my case, it would just be * to remove all of the variables in the child job, but in the previous requests, I've seen it requested like "SQL.*", which would add even more flexibility.

Thanks in advance for taking the time to read through my request.
Sponsor
Forum information
thomas
2017-09-07T12:00:56Z
Another way would be the possibility to pass in an object instead of loads of single variables. If I understand you correctly (simplified example):

You have 1 Child job, lets call it Child1. This job has no job variables predefined, but can take x number of variables from any parent jobs.

Parent1 calls Child1 with variables a, b and c. These are now defined in Child1 (because you check 'update job variable')
Parent2 later calls Child1 with variables a and b. But since variable c is already defined in Child1 now, it causes problems.

Is that correct?

If so, In my opinion it would be better to be able to pass in an object instead of x number of variables. Because then Child1, Parent1 and Parent2 could all have a parameter called say varObj. This could be a JSON object for example:

Parent1 passes in {a:1, b:2, c:3}
Parent2 passes in {a:2, b:4}

For those that are unfamilliar with JSON, Parent1 has defined an object with properties a, b, and c, with values 1, 2, 3 respectively.

Child1 then checks which sub-variables are defined in the object, and acts accordingly. This would resemble how JavaScript works.
No need to delete variables in Child1, since it always expects one and only object variable anyway.
ddtisysadmin
2017-09-07T12:53:39Z
Originally Posted by: thomas 

Another way would be the possibility to pass in an object instead of loads of single variables. If I understand you correctly (simplified example):

You have 1 Child job, lets call it Child1. This job has no job variables predefined, but can take x number of variables from any parent jobs.

Parent1 calls Child1 with variables a, b and c. These are now defined in Child1 (because you check 'update job variable')
Parent2 later calls Child1 with variables a and b. But since variable c is already defined in Child1 now, it causes problems.

Is that correct?


This is exactly the problem I'm having. Thank you for expressing it much better than I could have! 😄

Originally Posted by: thomas 


If so, In my opinion it would be better to be able to pass in an object instead of x number of variables. Because then Child1, Parent1 and Parent2 could all have a parameter called say varObj. This could be a JSON object for example:

Parent1 passes in {a:1, b:2, c:3}
Parent2 passes in {a:2, b:4}

For those that are unfamilliar with JSON, Parent1 has defined an object with properties a, b, and c, with values 1, 2, 3 respectively.

Child1 then checks which sub-variables are defined in the object, and acts accordingly. This would resemble how JavaScript works.
No need to delete variables in Child1, since it always expects one and only object variable anyway.



This would be a great approach. I had already considered trying to put the variables into an XML object, but eventually just used the option to pass variables, since it's already baked into VisualCron. I think the concept of passing objects and/or parameters would be a much better way to do what I'm trying to do anyway.

thomas
2017-09-07T14:52:24Z
Ok cool, then we agree. Maybe you can delete variable from the Api, I don't know as I don't use it. If not, the only way I can think of today is pretty dirty. I mean really awful but here goes :)

Create a job that calls Child1 with all possible variables, and passes in an empty string on all of them. In Child1, check the variables, and if they are empty strings, then do nothing.

In each of the parent jobs, start by calling this job, that essentially resets all the variables. So they stay in Child1, but have no effect.
Scroll to Top