Adding Custom Links to Action Menu using DoURLWarning JavaScript Function
-
Posted by Quest Editor
- Last updated 11/07/19
- Share
Sasank Vemana, Quest Guest Blogger | Blog content sourced from Sasank’s PeopleSoft Log
In the past, I wrote about how we can add custom links to the Branding – Action Menu at the system level.
Refer: Adding Custom Links to Fluid Branding
While testing this feature, I found that these custom links do not work in certain scenarios. For example, clicking those links from within the NUI Activity Guide framework (which is also used in Nav Collections).
I originally used the FieldChange event and the Response Class RedirectURL method to implement the redirection logic in Fluid Branding as shown below.
Since the Response Class RedirectURL method proved to be problematic in certain scenarios, I started investigating other options. In the process, I found this great delivered JavaScript function called DoURLWarning which is part of PT_HISTORY object in 8.55 (PT_PAGESCRIPT_FMODE object in 8.54).
DoURLWarning function allows us to redirect to a URL using javascript. Additionally, the function will take care of checking for any unsaved data in the current page and if there is any it will display the “Save Warning” message. If not, it will redirect to the URL in the parameter list.
To use the DoURLWarning function, I removed all the redirect logic from the FieldChange Event and added code in the RowInit event (as shown below) to utilize the DoURLWarning in combination with the Field Class JavaScriptEvents Property.
PeopleCode for Reference
Local string &redirectURL;
&redirectURL = “https://pe0ples0ft.blogspot.com/”;
CSK_PTBR_WRK.LINK1.JavaScriptEvents = “href=””javascript:DoURLWarning(‘” | EscapeJavascriptString(&redirectURL) | “‘)”””;
Demo
As we can see in the demo video, the custom link on the Action Menu works when invoked from the Activity Guide framework (which is also used in Nav Collections). The same approach described above can be used to implement custom links to internal PeopleSoft pages as well (e.g.: Process Monitor, Report Manager, etc.).
Save Warning Demo
Fluid UI New Window Feature Implementation
I used a similar technique as described above to implement the ‘New Window’ feature in Fluid UI as a custom link on the Branding – Action Menu.
Refer: Fluid UI – New Window Feature – Workaround
The only difference in the implementation is that instead of using the Response Class RedirectURL method (which would redirect/replace within the current window), I used the ViewContentURL method to open a new window as shown below.
We can see in the demonstration below that the same problem described for the custom links also exists for this New Window implementation.
To work around the problem, I took a similar approach and removed the existing logic from the FieldChange event and moved it to the RowInit event. In the RowInit event, I used the Field Class JavaScriptEvents Property in combination with the Window interface’s open method as shown below. Additionally, I also updated the logic to include the %Request.QueryString to the URL to make sure that none of the additional parameters are lost when opening the new window.
PeopleCode for reference
&fullURI = %Request.FullURI;
&pos1 = Find(“/psc/”, &fullURI);
&part1 = Substring(&fullURI, 1, &pos1 4);/p>
&part2 = Substring(&fullURI, &pos1 5, Len(&fullURI));
&pos2 = Find(“/”, &part2);
&part3 = Substring(&part2, 1, &pos2 – 1);
&part4 = Substring(&part2, &pos2, Len(&part2));
&pos3 = Find(“_”, &part3);
If &pos3 = 0 Then
&site = &part3;
Else
&site = Substring(&part3, 1, &pos3 – 1);
End-If;
&newWinURL = &part1 | &site | “_newwin” | &part4 | “?” | %Request.QueryString;
CSK_PTBR_WRK.NEW_WINDOW_PB.JavaScriptEvents = “onclick=””javascript:window.open(‘” | EscapeJavascriptString(&newWinURL) | “‘)”””;
Blog content sourced from Sasank’s PeopleSoft Log