Page 1 of 1
Single Related List multiple click spots
Posted: 20 Apr 2017
by GregReno
Hi.
I have a single list I am using for my related list.
I need to reuse it 10 times. All the fields are the same but 2 fields have different values depend which "Add New" linked that is clicked. I have set up each link to pass the proper variables.
All that is ok.
When i set up each of the Related List I use the appropriate view depending on which one and filter by my PT ID.
This seems to work except the views except the first is Related list is the only one with data. It has the correct data. The others are empty, even after adding info to it.
Will this work as I need it to or do I need to create 10 identical list?
Thank you.
Re: Single Related List multiple click spots
Posted: 21 Apr 2017
by Dmitry Kozlov
Hi,
Here I put two Related Items getting data from the same list onto a form, picked different views, and set up filtering. Everything looks right:

- 2relateditems.png (15.98 KiB) Viewed 2611 times
Re: Single Related List multiple click spots
Posted: 21 Apr 2017
by GregReno
Thanks. Looks like something in my coding.
When I comment it out it seems to work right. But I need to add set the TC and AGName fields manually.
I may need to take another approach.
What I am doing now.
// Put here the link to the specific New form and pass additional parameters:
//var cat = fd.field('Catagory').control().value()
//var newFormUrl = '/sites/resources/Lists/Contacts/NewForm.aspx?Catagory=' + cat;
var newFormUrl1 = '/sites/CRFs/Lists/Observations/New.aspx?TC=1. Rituxan Consumables Collection&AGName=N/A';
var newFormUrl2 = '/sites/CRFs/Lists/Observations/New.aspx?TC=2. Reconstitution of IV Rituxan in Pharmacy/ Sign-off of Prepared Rituxan Bag&AGName=Rituxin';
var newFormUrl3 = '/sites/CRFs/Lists/Observations/New.aspx?TC=3. Peripheral Access Insertion&AGName=N/A';
This maybe one thing. I when testing newFormUrl1I get dumped back on the first record after entering my info.
// Next 3 lines are required to open form in a dialog.
//var uri = new URI(newFormUrl1);
//var url = uri.getLastPathSegment();
//g_useDialogAlwaysList.push(url.toLowerCase()); --Throws error - Uncaught ReferenceError: g_useDialogAlwaysList is not defined
// Here we replace the standard 'New item' link with our custom link:
$('.ms-list-addnew a').eq(0).attr('onclick', 'NewItem2(event, "' + newFormUrl1 + '");return false;');
$('.ms-list-addnew a').eq(1).attr('onclick', 'NewItem2(event, "' + newFormUrl2 + '");return false;');
$('.ms-list-addnew a').eq(2).attr('onclick', 'NewItem2(event, "' + newFormUrl3 + '");return false;');
Maybe I have it all wrong.
I know when I get it newFormUrl1 right I will need to get newFormUrl2 through newFormUrl11 working. Occasionally I get thrown back to the first record.
Re: Single Related List multiple click spots
Posted: 24 Apr 2017
by GregReno
Passing the values I need is not working so well. Getting the form to return to the current record is not working so well.
Is there a way to determine which link was clicked? If I can determine this I can populate the fields needed according to the link I clicked.
Thank you.
Re: Single Related List multiple click spots
Posted: 25 Apr 2017
by Dmitry Kozlov
Hi Greg,
Instead of calling
NewItem2, you can define your own global function, ex.: window._NewItem = function(event, url, param) {} and pass a parameter depending on which link a user clicked:
Code: Select all
$('.ms-list-addnew a').eq(0).attr('onclick', '_NewItem(event, "' + newFormUrl1 + '", 'LINK1');return false;');
Then inside the
_NewItem method call the
NewItem2 link with the correct arguments.