View and Navigation Stack - visible server-side ?

WilliamHazelrig
Giga Contributor

Is there any way to determine the current view or examine the navigation stack from the server side?

I'm trying to write a condition for a Business Rule or UI Action which applies only to the Mobile view (specifically, either block certain state-change updates when submitted from the Mobile view, or make the relevant UI Action unavailable from the Mobile view). I had hoped that GlideStack might have what I needed, but I could not find any relevant documentation for it in the wiki.

1 ACCEPTED SOLUTION

WilliamHazelrig
Giga Contributor

Valor,

Thank you; I was able to get what I needed from gs.getSession().getStack(), by popping the last item from the stack and then pushing it back on (to avoid actually changing the stack).

With regard to RP:
It appears that RP is not available in the server-side portion of UI Action code, either; when I created a test form with a "Msg" field (u_msg) and a UI Action named "Foo" with the code below, clicking "Foo" causes the "Msg" field to be valued with "undefined".

current.u_msg = typeof RP;
if ('undefined' == current.u_msg)
{ current.u_msg = typeof rp; }
action.setRedirectURL(current);
current.update();

My alternate solution was a Script Include named "getLastUIView" (code below), which I now use in my UI Action condition line (i.e. "(getLastUIView() != 'Mobile')" to hide the UI actions which are inappropriate for the Mobile view.

function getLastUIView()
{ var Stack = gs.getSession().getStack();
var LastURL = Stack.pop();
Stack.push(LastURL);
LastView = '' + LastURL;
if (LastView.search(/sysparm_view\=/i) >= 0)
{ LastView = LastView.substring(LastView.search(/sysparm_view\=/i) + 13);
return LastView.replace(/^([^&%]*).*$/,"$1");
}
else
{ return ''; }
}


View solution in original post

4 REPLIES 4

Valor1
Giga Guru

If I'm not mistaken,


RP.getViewID()
will do the trick.

Additionally, if you need the stack:


var stack = gs.getSession().getStack();


I'll probably get banned for posting this, but last time I checked, these were the keys in RP (YMMV):


class
dialog
encodedQuery
equals
escaped
fileActionsOnly
gaugeHeight
gaugeId
gaugeName
gaugeType
gaugeWidth
getClass
getEncodedQuery
getGaugeHeight
getGaugeId
getGaugeName
getGaugeType
getGaugeWidth
getListControl
getMedia
getParameterValue
getParameters
getReferringURL
getRelatedQuery
getReportType
getStartingView
getViewID
getViewManager
getWindowID
getWindowProperties
hashCode
homePage
interactive
isChartDetailOnReport
isDialog
isEscaped
isFileActionsOnly
isHomePage
isInteractive
isManyToMany
isOneToMany
isPopup
isPortal
isPreview
isPrint
isReadOnly
isRelatedList
isSearch
isSmallCaption
listControl
manyToMany
media
notify
notifyAll
oneToMany
parameters
popup
portal
preview
print
putParameters
readOnly
referringURL
refreshNav
relatedList
relatedQuery
reportType
search
setChartDetailOnReport
setDialog
setEncodedQuery
setEscaped
setFileActionsOnly
setGaugeHeight
setGaugeId
setGaugeName
setGaugeType
setGaugeWidth
setHomePage
setListControl
setManyToMany
setMedia
setOneToMany
setPopup
setPortal
setPreview
setPrint
setReadOnly
setReferringURL
setRefreshNav
setRelatedList
setRelatedQuery
setReportId
setSearch
setSmallCaption
setView
setViewManager
setWindowID
setWindowProperties
smallCaption
startingView
toString
viewID
viewManager
wait
windowID
windowProperties


WilliamHazelrig
Giga Contributor

Valor,

I tried setting up the following code in an on Insert Business Rule on a test form which has a field named u_msg; unfortunately, it doesn't seem to work. I believe I'm missing the step required to get the "RP" object to begin with. Here is my test code:

current.u_msg = RP.getViewID();


RP is a global variable available in UI Actions (it stands for RenderProperties).
Really, it's available in the user interaction layer--so you can use it in default values (sometimes), and script areas immediately preceding or following some UI transaction

If you need it in a business rule, I'd have to look up what's available in the stack--let me know.


WilliamHazelrig
Giga Contributor

Valor,

Thank you; I was able to get what I needed from gs.getSession().getStack(), by popping the last item from the stack and then pushing it back on (to avoid actually changing the stack).

With regard to RP:
It appears that RP is not available in the server-side portion of UI Action code, either; when I created a test form with a "Msg" field (u_msg) and a UI Action named "Foo" with the code below, clicking "Foo" causes the "Msg" field to be valued with "undefined".

current.u_msg = typeof RP;
if ('undefined' == current.u_msg)
{ current.u_msg = typeof rp; }
action.setRedirectURL(current);
current.update();

My alternate solution was a Script Include named "getLastUIView" (code below), which I now use in my UI Action condition line (i.e. "(getLastUIView() != 'Mobile')" to hide the UI actions which are inappropriate for the Mobile view.

function getLastUIView()
{ var Stack = gs.getSession().getStack();
var LastURL = Stack.pop();
Stack.push(LastURL);
LastView = '' + LastURL;
if (LastView.search(/sysparm_view\=/i) >= 0)
{ LastView = LastView.substring(LastView.search(/sysparm_view\=/i) + 13);
return LastView.replace(/^([^&%]*).*$/,"$1");
}
else
{ return ''; }
}