Create Child jobs - access custom property of parent job

1105
1
Jump to solution
04-22-2012 08:14 PM
FraserHand
Occasional Contributor III
Hi All,
I want to change the create child job step to create the amount of jobs as stored against the parent job. Has anyone got a code snippet for doing this? Or just for accessing the parent custom properties?
Thanks,
Fraser
0 Kudos
1 Solution

Accepted Solutions
FraserHand
Occasional Contributor III
Found it:
You have to get to the JTXAuxRecord.
Code snippet example

IJTXAuxProperties someProps = pParentJob as IJTXAuxProperties;
            string[] sExtPropTableNames = someProps.ContainerNames;
            for(int i = 0;i < sExtPropTableNames.Length;i++) {
                IJTXAuxRecordContainer ipExtendedPropTable = someProps.GetRecordContainer(sExtPropTableNames);
                Console.WriteLine(ipExtendedPropTable.TableAlias);
                IJTXAuxRecordSet ipExtendedPropertyRecords = ipExtendedPropTable.GetRecords();
                for(int j = 0;j < ipExtendedPropertyRecords.Count;j++) {
                    // Get each record for this job from the extended property table
                    IJTXAuxRecord2 ipExtendedPropRecord = ipExtendedPropertyRecords.get_Item(j) as IJTXAuxRecord2;
                    for(int k = 0;k < ipExtendedPropRecord.Count;k++) {
                        // Cycles through each of the extended property fields for that record
                        // Only fields that have been marked as visible for the job type will be returned
                        Console.WriteLine("  Field alias: " + ipExtendedPropRecord.get_PropAlias(k));
                        Console.WriteLine("  Field value: " + ipExtendedPropRecord.get_Data(k).ToString());
                    }
                }
            }

I stored the custom props table that had the extended property, and the name of the property and placed it on the create child args dialog. Then in the execute step it looks it up and pulls out how many jobs it needs to create.

F

View solution in original post

0 Kudos
1 Reply
FraserHand
Occasional Contributor III
Found it:
You have to get to the JTXAuxRecord.
Code snippet example

IJTXAuxProperties someProps = pParentJob as IJTXAuxProperties;
            string[] sExtPropTableNames = someProps.ContainerNames;
            for(int i = 0;i < sExtPropTableNames.Length;i++) {
                IJTXAuxRecordContainer ipExtendedPropTable = someProps.GetRecordContainer(sExtPropTableNames);
                Console.WriteLine(ipExtendedPropTable.TableAlias);
                IJTXAuxRecordSet ipExtendedPropertyRecords = ipExtendedPropTable.GetRecords();
                for(int j = 0;j < ipExtendedPropertyRecords.Count;j++) {
                    // Get each record for this job from the extended property table
                    IJTXAuxRecord2 ipExtendedPropRecord = ipExtendedPropertyRecords.get_Item(j) as IJTXAuxRecord2;
                    for(int k = 0;k < ipExtendedPropRecord.Count;k++) {
                        // Cycles through each of the extended property fields for that record
                        // Only fields that have been marked as visible for the job type will be returned
                        Console.WriteLine("  Field alias: " + ipExtendedPropRecord.get_PropAlias(k));
                        Console.WriteLine("  Field value: " + ipExtendedPropRecord.get_Data(k).ToString());
                    }
                }
            }

I stored the custom props table that had the extended property, and the name of the property and placed it on the create child args dialog. Then in the execute step it looks it up and pulls out how many jobs it needs to create.

F
0 Kudos