Getting Affected Item Attributes from PSR – Script PX

I’m beginning to play around with Script PXs for the first time and I could use some help understanding the basics.

I’ve created some very simple scripts for getting and setting attributes from a cover page and what not, but I’m having trouble working with the Affected Items table on a PSR. I’d like to have a Script that pulls either all attributes from the row, or a script that gets a specific attribute. My problem seems to be that I can’t access Affected Item row attributes the same as I do with Title Block Attributes.

I’ve seen a lot of references online to “constants” like the one listed below:
(ServiceRequestConstants.ATT_AFFECTED_ITEMS_LATEST_CHANGE)

But I can’t seem to find this documented anywhere, so I don’t know how to access any attributes other than those directly called out in a sample script somewhere. Any guidance would be greatly appreciated, and generic sample code that I could dissect would be even better.

Add Comment
2 Answer(s)

Hi Brett,

If you want to get the attribute details you need to :

1. Load the affected item table in SDK
2. Iterate the Table
3. For each iteration you can fetch details of each attachment row.

For example: Suppose you have loaded your current PSR object as

IServiceRequest psrObj = (IServiceRequest) agileSession.getObject(ServiceRequestConstants.CLASS_PRODUCT_SERVICE_REQUEST_BASE_CLASS, arg1);

Now load the attachement table as:

ITable attachmentTab=psrObj.getTable(ServiceRequestConstants.TABLE_AFFECTEDITEMS);

Now iterate the table to get the table rows, for each iteration you can extract the details as per your requirement:

Iterator itr=attachmentTab.getTableIterator();

while (itr.hasNext()) {
IRow row=(IRow) itr.next();
String fileName= row.getValue(ServiceRequestConstants.ATT_ATTACHMENTS_FILE_NAME).toString();
String fileType= row.getValue(ServiceRequestConstants.ATT_ATTACHMENTS_FILE_TYPE).toString();
String checkInUser=row.getValue(ServiceRequestConstants.ATT_ATTACHMENTS_CHECKIN_USER).toString();

…… and so on
}

Agile User Answered on April 4, 2019.
Add Comment
Best answer

Update: I found that the Oracle Sample Code contains HTML files that document all of the API classes and constants, and this has significantly helped me access the attributes that I needed. Kunal’s answer is also a great sample of how to get and iterate through an object’s table rows.

https://www.oracle.com/technetwork/indexes/samplecode/agile-2684218.html

The link above takes you to Oracle’s sample code. The API Documentation is listed in the 9.3.#_SDK_Samples.zip file.

Agile User Answered on April 4, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.