Fill an array on change record, post expression in link file (1590 Views)
Reply
Frequent Advisor
john evil
Posts: 63
Registered: ‎12-31-2009
Message 1 of 6 (1,590 Views)
Accepted Solution

Fill an array on change record, post expression in link file

[ Edited ]

I need to link two values from CI records to Change record and to be able to search Change records where either of these is true.

 

Device table - I have added fields x.service and x.area (logical) and these values has to be linked / copied to change record.

On cm3r-table I have added an structured array:

CI.info (array)

   CI.info (structure)

     x.service (logical)

     x.area (logical)

     CI.name (character)

 

Problem is how I can fill this array when user fills assets array on Change record?

 

I have tried to modificate cm3r link record but I could get it working as planned.

Please use plain text.
Frequent Advisor
john evil
Posts: 63
Registered: ‎12-31-2009
Message 2 of 6 (1,583 Views)

Re: Fill an array on change record

I tested this configuration and it's partly working

 

- added "$fill.recurse=true" to assets link line expressions

- added link line after assets line in cm3r-link record

  Field (from/source): CI.name - File: device - Field (To/Target): logical.name

Expressions:

$fill.structre={3, "CI.info"}

if null(cursor.line(1) in CI.name in $File) then ($query=true) else ($query="logical.name#\""cursor.line(1) in CI.name in $File+"\"")

 

Source          Target

3                     logical.name

1                     x.service

2                     x.area

Post Expressions

$fill.recurse=false

 

I could get the first line in new array filled, second one didn't.

 

Other issue - how I could clear line from the array if one CI is removed from assets array?

 

What do you think? Should this be done from format control and fill the array always when the record is saved?

Please use plain text.
Frequent Advisor
john evil
Posts: 63
Registered: ‎12-31-2009
Message 3 of 6 (1,564 Views)

Re: Fill an array on change record

[ Edited ]

Changed the CI.name link line.

 

Expressions:

$fill.structre={3, "CI.info"}

$Lci=cursor.line(1);$L.ci.name=$L.ci in assets in $File

$query="logical.name=\""+$L.ci.name+"\""

if ($L.ci.name="") then ($L.ci in CI.info={})

 

Source Target

3            logical.name

1            x.service

2            x.area

 

Post Expressions:

$fill.recurse=false

 

First line in assets is filled to table and x.service and x.area values linked.

Second line same

Third line - assets value doesn't fill to the table! This is strange?

 

Second problem - how I can remove value from second line if user removes an Affected CI?

 

Anyone, ideas? Founders, good ideas?

Please use plain text.
Frequent Advisor
john evil
Posts: 63
Registered: ‎12-31-2009
Message 4 of 6 (1,540 Views)

Re: Fill an array on change record

Getting something to work. Now the solutions has two phases.

 

1. Opened record, add CI's

- I have modified cm3r link record, added line to assets post expressions. Whole record is:

Field (From/Src): assets  File (To/Target): device   Format (To/Target): device   Field (To/Target): logical.name

 

Expressions:

$fill.recurse=false
$L.idx=nullsub(cursor.line(1), 1);if gui() then ($fill.search.format="device.cm3rrfc.search")
if (not null($L.idx in assets in $File)) then ($query="logical.name#\""+$L.idx in assets in $File+"\"") else ($query="true")
if ($G.multi and not null(company in $File)) then $query+=" and (company=company in $File or company=\"DEFAULT\")"
if $query#"true and " then ($L.void=strclpl($query, 9))

 

Source Field: assets         Target Field: logical.name

 

Post Expressions:

$fill.exact=true;$L.idx=nullsub(cursor.line(1), 1);3 in $L.idx in CI.info in $File=logical.name in $L.target;2 in $L.idx in CI.info in $File=x.area in $L.target;1 in $L.idx in CI.info in $File=x.service in $L.target

 

This is working if user is filling the assets array and found CI logical.name is exactly unique. But if there is two CI with names: "XYZ" and "XYZ -application", then will the "Select Related Records" window open, user selects correct CI and it will be always filled to first line in CI.info array.

 

I think that $L.idx value is gone when the "Select Related Records" window opens and this is the reason why CI is posted to wrong line in the array. How I could maintain the value from Expressions to Post Expressions even if there is other window at the middle of the filling process? With global variable?

 

2. Phase is done with format control calculations when users Saves the record. Calculation fills the CI.info array and then queries device table and fills the correct values. This is working.

Please use plain text.
Frequent Advisor
john evil
Posts: 63
Registered: ‎12-31-2009
Message 5 of 6 (1,532 Views)

Re: Fill an array on change record

changed $L.idx to $idx and this is working.

Please use plain text.
Advisor
tbokhary
Posts: 19
Registered: ‎06-27-2011
Message 6 of 6 (1,395 Views)

Re: Fill an array on change record

Could you look at my question and see if your approach can work for mine. I am trying to fill some fields in a table array or VJ when Affected CIs are filled. Something like subtype, status, assignment etc.

http://h30499.www3.hp.com/t5/HP-Service-Manager-Service/Need-help-creating-Virtual-Join-table-on-arr...
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation