Home > Work > Determining delegation mode and user via jQuery #in #ProjectServer #PS2010 #SP2010

Determining delegation mode and user via jQuery #in #ProjectServer #PS2010 #SP2010

In my current project I have recently had the requirement to determine whether Project Server 2010 was in delegation mode.

If the user was in delegation mode, we then passed the unique Display Name of the delegation user and passed it to a web service to return more data about the resource.

DelegateScreenshot

The information bar in PS2010 lets us know that we are in delegation mode and in jQuery we can interrogate this to get the information we need.

The following code uses jQuery to determine if we are in delegation mode and sets the Display Name and isDelegate variables accordingly:

1 <script type='text/javascript'> 2 var delegateName = ""; 3 var isDelegate = 0; 4 5 _spBodyOnLoadFunctionNames.push("checkDelegateMode"); 6 7 function checkDelegateMode() { 8 //Am I in delegate mode? Check the SP2010 Information bar for the word delegate 9 $('span[id=status_1_body]').each(function() { 10 11 var textEval = $(this).text(); 12 13 if (textEval.indexOf('delegate') != -1) { 14 //The word delegate has been found - lets find the delegate Resource Display Name 15 16 var strongCount = 0; //The delegate is the first item surrounded in the <STRONG> tag 17 18 $(this).find("strong").each(function() { 19 20 if (strongCount == 0) { 21 delegateName = $(this).text(); //Store the display name 22 isDelegate = 1; //Set that the delegate has been found 23 24 } 25 26 strongCount = strongCount + 1; 27 28 }); 29 } 30 31 }); 32 } 33 </script>

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: