3

I want to ask if there is a way to remove default user from SharePoint calendar. I am adding users via javascript, so default user is not needed.

Maybe it is possible to do this by editint SharePoint 2010 function ? From source code I can see a function that is automatically generated:

<script type="text/javascript">
function _initTRAWebPartWPQ3()
{
var toolbarData = new Object();
toolbarData['ToolbarData'] = .....;
toolbarData['CurrentUserInfo']=[{id:'172',loginName....;
}
</script>

Is it possible by adding javascript to page to edit toolbarData object ? For example:

function _initTRAWebPartWPQ3(x){
    toolbarData['CurrentUserInfo'] = x;
    };

ExecuteOrDelayUntilScriptLoaded(_initTRAWebPartWPQ3('Stewe'), "sp.ribbon.js");
1
  • I would like to know if you managed to find the solution to this problem. Thank you!
    – MariusK
    Jan 8, 2014 at 14:35

1 Answer 1

1

Yes it is, but you will have to make sure your script patches the function at the right time.

For this your code that sets toolbarData['CurrentUserInfo'] should set it to {} and empty object and have it in a script block which also ensures that the ribbon.js is loaded prior.

Check typeof SP.Ribbon !== 'undefined' and if it is then load it and patch, if it is not then just patch.

You may also want to "Duck punch" the _initTRAWebPartWPQ3 function by copying it into a temporary variable, writing your own and calling the temporary variable inside your own version. This way your function will get called instead of the OOTB function and your function will call the old temporary one.

2
  • This is a way... Is it possible to do that with external JavaScript? Dec 2, 2013 at 15:26
  • Oh Yes, you can overwrite any javascript in memory with your own as long as the order of precedence is correct. Then call a version of the original you store in a temporary variable where you want, effectively shimming your code into the original.
    – Hugh Wood
    Dec 2, 2013 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.