Discussion

How to access index of WorkAttachList.pxResults

I have multiple attachments as WorkAttachList.pxResults. Now, i am downloading the attachments using javascript. Can someone let me know that how to access index in this process so that i can download the attachment of the row where i click ?
Unable to find the index using
int indexCount = tools.getActive().indexOf();
in js. This code is not working in javascript file.
Please suggest somethng guys ??????
Thanks

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Comments

Keep up to date on this post and subscribe to comments

August 30, 2012 - 12:01am

What are you using , listview or repeat layout?
If you are using listview then look at ootb single / double click. Function , it will have a parameter called nrow(I don't remember exact name ,but it should be ..) ,that will give u index.
If you are using repeat layout ,you have to make a column prop hyperlink .and reporting_link control will help you.

If above doesn't solve your problem ,reply with your approach

August 30, 2012 - 3:40am

I am using grid repeat layout for the attachments. Can you please describe the procedure to get the index as I am newbie to PEGA.
The process I am using is as follows:

On click of attachment, a javascript is being called, from where an activity is getting called. In activity, java code is written to download the attachment. Please provide me code snippets or details so that i can get the specific attachment.
Thanks

quote:


Originally posted by AANAND84

What are you using , listview or repeat layout?
If you are using listview then look at ootb single / double click. Function , it will have a parameter called nrow(I don't remember exact name ,but it should be ..) ,that will give u index.
If you are using repeat layout ,you have to make a column prop hyperlink .and reporting_link control will help you.

If above doesn't solve your problem ,reply with your approach


August 30, 2012 - 8:49pm

Refer to repeating_link control and pass the index to your activity by modifying your JavaScript.
If you still don't get it. Post your js code .

August 31, 2012 - 3:16am

test_method = {
OpenFile: function(id) { alert(id.value);

// var ind = '<pega:reference name="Param.Index"/>';
var ind = '<%=tools.getSaveValue("index")%>';
alert(ind);
var oSafeURL = new SafeURL("TestCover.TempTstActivity");
var sReturn = httpRequestAsynch(oSafeURL.toURL());
alert(sReturn);
}
}

This is the js which is being called on click of attachment. The navigation rule is used here to call the js. First prblem is like how to get the index of attachment in js, then how to get the same in activity to download that attachment?
Please help..

quote:


Originally posted by AANAND84

Refer to repeating_link control and pass the index to your activity by modifying your JavaScript.
If you still don't get it. Post your js code .

September 4, 2012 - 11:25pm

i don't know a straight way but following code might help you

<script>
var rowindex;
var selectedIndex;
function GetSelectedRowIndex()
{
var table = document.getElementById("bodyTbl_right");
var trs = table.getElementsByTagName("tr");
for(var i=0;i<trs.length;i++)
{

var rowObj=trs(i);
rowindex=rowObj.getAttribute("PL_INDEX");
if (rowindex != null)
{
var tds = rowObj.getElementsByTagName("td");
var cellObj=tds(1);
var Clas= cellObj.className;
var myRegExp = /selected/;
var findExp = Clas.search(myRegExp);
if (findExp!= -1)
{
selectedIndex=rowindex;
return selectedIndex;
break;
}

}

}
}

function RunActivityAsynch()
{
var Index=GetSelectedRowIndex();
//alert(Index);
var oSafeURL= new SafeURL("Classname.activityname");
oSafeURL.put("RowIndex",Index);
var strReturn = httpRequestAsynch(oSafeURL.toURL(),null, 50, 100);
}

In the activity you can access the index as Param.RowIndex

</script>