Getting the previous Page's ID

Posted by IramK on 11-Mar-2015 11:15

Hello,

I have a situation described below and I would like to get the previous Page's view ID to know where the click is coming from. Basically I have three objects: A, B and C.

Application 1: Object A and B. They have a relationship with each other (M-M for eg). A is also related to C.

Application 2: Object B and C. They have a relationship with each other(M-M).C is also related to A.

Now when I am in application 1 and I click on Attach 'C' the modal selector page pops up, I would like to know that I am in application 1 so that when the user clicks on the attach button I can do some specific behavior on the generic selector page. Likewise if I am on application 2 and if the user clicks on Attach 'C', I would like to know that I am in application 2 to carry out specific behavior with my generic selector page. Could anyone possibly suggest the best way to get to know where the attach button click is coming from i.e. application 1 or application 2? Looking forward to your replies.

Posted by Orchid Corpin on 16-Mar-2015 13:14

Hi Iramk,

I see, here is another option I found, this will let you extract pageId from URL and not from token, in your selector page try the code below.

<script>
	function getUrlParameter(sParam)
	{
		var sPageURL = window.location.search.substring(1);
		var sURLVariables = sPageURL.split('&');
		for (var i = 0; i < sURLVariables.length; i++) 
		{
			var sParameterName = sURLVariables[i].split('=');
			if (sParameterName[0] == sParam) 
			{
				return sParameterName[1];
			}
		}
	} 
	
	var pID = getUrlParameter('pageId');
	alert("pID: "+pID);
</script>


Credits to: http://stackoverflow.com/questions/19491336/get-url-parameter-jquery

Hope this may help.

Regards,

Orchid

All Replies

Posted by Orchid Corpin on 11-Mar-2015 18:01

Hi IramK,

Is your attach button from both Apps are not customized? When we click attach I think we are not redirected to other page it only opens a modal window and so you don't need to get previous page.

In your view page go to Design Page > Add Script Component > in 2nd drop-down select ID of View Page (this is the page ID)

Hope this may help.

Regards,

Orchid

Posted by IramK on 13-Mar-2015 04:44

[mention:e6fb884e9c7b45a2a638966c06dc0941:e9ed411860ed4f2ba0265705b8793d05] Yes but when that modal window opens and you get the View Page ID of the current page. How will I be able to get the view page ID of the current page in my modal window i.e. how can my selector page get the current view page's ID?

Posted by Orchid Corpin on 13-Mar-2015 16:38

Hi Iramk,

I see, in your modal page or the selector page of your related object.

Then, in your script component select the related object (in the first drop-down) and in second drop-down select the "ID of View Page". Most likely the same as the above but this time you are from the related object.

Hope this may help.

Regards,

Orchid

Posted by IramK on 15-Mar-2015 14:57

Ok thats fine. That's achievable. One last question along the same lines: If I would want to get the ID of View Page if I did not know which related Object it was from, is there a way to achieve that? That Attach option is lets say related to 10 different objects and when that attach button is clicked I would want to know which object has clicked on the attach button. Just trying to get it to work more dynamically rather than what you suggested.

Posted by Orchid Corpin on 16-Mar-2015 13:14

Hi Iramk,

I see, here is another option I found, this will let you extract pageId from URL and not from token, in your selector page try the code below.

<script>
	function getUrlParameter(sParam)
	{
		var sPageURL = window.location.search.substring(1);
		var sURLVariables = sPageURL.split('&');
		for (var i = 0; i < sURLVariables.length; i++) 
		{
			var sParameterName = sURLVariables[i].split('=');
			if (sParameterName[0] == sParam) 
			{
				return sParameterName[1];
			}
		}
	} 
	
	var pID = getUrlParameter('pageId');
	alert("pID: "+pID);
</script>


Credits to: http://stackoverflow.com/questions/19491336/get-url-parameter-jquery

Hope this may help.

Regards,

Orchid

Posted by IramK on 16-Mar-2015 14:31

Ok that's fair enough. I have a function that does the URL parameter parsing so I could just use that. Just thought if there was any other better way of achieving this. But thanks for your reply. It definitely is worth knowing.

Cheers [mention:e6fb884e9c7b45a2a638966c06dc0941:e9ed411860ed4f2ba0265705b8793d05] .

This thread is closed