Targeting a Panel via URL (or: How to Idiot-Proof Notifications)


Userlevel 6
Badge +15

Panels.


Panels never change.

 

But what DOES change is who can see them, and when. This is what initiated my most recent client request: "Make sure that when the Manager goes into the form, that they can only see the Manager panel, and the Software panel - and not the other two." 

 

"Simple!" I replied. Our panels are JavaScript controlled beauties; a sight to behold. Easy to hide using Nintex rules.

 

I spoke too soon.

 

"Also," they began, "Ensure that the Manager is taken directly to the Manager panel when they open their notification link."

 

My endless Googling and Nintexoogling of "target panel" was fruitless; if nothing else, I hope this blog will cement the words "target panel" forever in the search terms so that I can help future Rhias of the world come to this solution:

 

Step 1) Determine your code word. For me, it was "managers" and "software". We will focus on "managers" for this example.

 

Step 2) Ye olde JavaScript. Plop this into your Custom JavaScript settings:

 

NWF$( document ).ready(function() {
  if(location.search.indexOf("manager") > -1) {
  showPanelManager();
  }
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

Explanation: This JS looks at the URL, and checks to see if the word "manager" is in it. If it is, it runs the JS function "showPanelManager()" which is what controls our Manager panel.

 

Step 3) In your workflow, wherever the URL is going to be doled out to a manager, append either:

               a) If after .aspx, add a ?manager (.aspx?manager)

               b) If after other data (such as ID=360), add an &manager (ID=360&manager)

 

And, simple as that, you can now send your user directly to whichever panel is appropriate to them.

 

AND ... even if you don't need this ... think of all the cool things you could do by using a URL in this way! Append a word, and magically run ANY function! NEAT.

 

Any questions? Comments? Let me know! I'd also like to hear of the better ways to accomplish this - I am sure they exist - as well as your ideas for how else this could be used. happy.png 


12 replies

Userlevel 4
Badge +7

Rhia Wieclawek

This is an awesome approach.

Whenever i have had to use this functionality, I have the manager field on the form (manually populated or auto populated through JavaScript. I little teaser for a future blog post!) and then use a rule on the panel set to hide using this formula:

not(userEquals(Manager,Current User))

Where manager is the named control of the manager field.

Using your method opens up the possibility of custom functions run based on a query string value. Awesome.

Userlevel 5
Badge +14

I use to use following script.

it takes supplied anchor from URL, and if it recognizes it's a control name or javascript control variable it translates it to respective control id. that makes browser to navigate to the control.

I found it independent of form/application and specific customized handling routine.

NWF.FormFiller.Events.RegisterAfterReady(function () {
   //check to see if any anchor is provided in URL
   if (window.location.hash.length){     
     //get the anchor and remove hash mark
     var anchorTag = window.location.hash.replace(/#/,'');
     //check to see if anchor is recognized as control's javascript variable
     if (NWF$('#' + window[anchorTag]).length){
         //set/change anchor to ID of control identified by javascript variable
         window.location.hash = "#" + NWF$("#" + window[anchorTag])[0].id;
      }else //check to see if anchor is recognized as control's name
        if (NWF$("[data-ControlName='" + anchorTag  + "']").length){                             
           //set/change anchor to ID of control identified by control name
           window.location.hash = "#" + NWF$("[data-ControlName='" + anchorTag  + "']").find('.nf-associated-control').attr('id');        
        }
    }
})
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Userlevel 6
Badge +15

‌ - this is interesting to me - as I am a total JavaScript newbie. I am wondering if you would mind giving a brief explanation of what each line is doing? That might be helpful for others as well!!

Badge +6

‌ Very cool, thanks a lot! :-)

Userlevel 6
Badge +15

And thank YOU for your contributions as well, sir!

Userlevel 6
Badge +15

Manager automatically populated through JavaScript!? Like, looking at the Current User's organizational hierarchy!? You have piqued my interest, sir!

Userlevel 4
Badge +7

Exactly that, I will blog it on Monday. Queries the user profile for manager and populates people picker control. 

Userlevel 5
Badge +14

is it better now?

Userlevel 6
Badge +15

Yes! This is excellent! Thank you so much ‌ <3

Userlevel 7
Badge +17

+1 for having a cartoon image that looks like you!

Userlevel 6
Badge +15

Well, I drew it, so it had better! I did freelance illustration for a long time  this is the top of a cartoon I did of myself as a mermanatee - manatees are awesome.

If you want a cartoon of yourself like that (you don't have to be half manatee) I'm glad to make one for you!

Userlevel 7
Badge +17

I'm IN!

Reply