Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, July 6, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Web Forums - SalesLogix Web Platform & Application Architect
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: Hiding NavBar/ToolBar Items at Runtime
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Jan 09 4:55 AM
Hi,

Does anybody know if there is a way to hide NavBar/ToolBar items at run time? I can see a mnuNew.ascx (for the New...menu) in the deployment folder but any events I put in here do not fire. I am aware that this folder gets regenerated everytime you deploy but that is something that can be managed - it is more essential that we can get the items hidden/shown according to a user role.

Any thoughts gratefully received!

Thanks,
Nick
[Reply][Quote]
Todd Herman
Posts: 52
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Jan 09 3:32 PM
Just want to second this question. I need to disable the navbar and menu options for certain users to disable their ability to add/Edit/View campaigns, leads and tickets in the 7.2.2 web client. I tried originally using OOB user security in Administrator but it doesn't seem to work at all in the web client. Can this be scripted based on members of a team? i.e. I have a "Standard Navbar" team and a "Minimum Navbar" team that can only see Accounts/Contacts/Activities?

Very grateful indeed if there is a working example of this somewhere.

Thanks,
Todd
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 Jan 09 3:48 PM
This can be done easily.

I have 2 cases to handle:

a) Menu Entries available only for Users that belong to certain Roles.
We have added code to the Base.Master to Add these menus dynamically if the user belongs to a given group:

Sage.Platform.WebPortal.Services.IMenuService mnuSrc = ToolBar.WorkItem.Services.Get();
if (IsRoleMatch("MyRole",userService.UserId.ToString() ))
{
NavItem menuItemMR = new NavItem();
menuItemMR.Text = "MyRole Menu";
menuItemMR.ID = "MyRole";
menuItemMR.Target = "_new";
menuItemMR.SmallImageURL = "~/images/icons/MyRole.gif";
menuItemMR.NavURL = "MyRole.aspx";
mnuSrc.AddMenuItem("MyCustomMenu", menuItemMR);
}



b) Menu Entries available based on Conditions of the Contact (in this case, if the Title field is populated)
We have added code to the ContactDetail.aspx to Enable/Disable these menus dynamically.

protected void disableMenus(string strSSN)
{
Sage.Platform.WebPortal.Services.IMenuService mnuSrc = this.PageWorkItem.Services.Get();
if (!string.IsNullOrEmpty(strTitle))
{
mnuSrc.EnableMenuItem("myRole", "MyCustomMenu");
}
else
{
mnuSrc.DisableMenuItem("myRole", "MyCustomMenu");
}
}

[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jan 09 9:29 AM
Thanks very much Raul, with a touch of modification I got it working great for menu items by configuring base.master. Is it possible to hide Nav Items also? I tried using the same technique but the Nav collection doesnt appear to be accessible in the same way (i.e. I cant see any Sage.Platform.WebPortal.Services.INAVService etc.)

Many thanks,
Nick
[Reply][Quote]
Ken Poggensee
Posts: 71
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jan 09 9:44 AM
I have the same question...

I am probably missing something silly here, but where in the base.master do I plug that snippet into? I tried a couple variations and could not get it to work. I need to be able to hide some of the NavBar items based on either the user having a specific role (or part of a team if need be).

--Ken--
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jan 09 10:34 AM
Well, in order to hide toolbar items you open base.master in AA (under SupportFiles\Masters), and within the Page_Load event just add you code to enable/disable/remove toolbar items (thats the menu area at the top) - code as per Raul's email. As for the left navbar I am stumped
[Reply][Quote]
Ken Poggensee
Posts: 71
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jan 09 10:45 AM
It's the left navbar that I am trying to hide as well. Basically I need to hide calendar/activities/process/library if user is part of a team or what not.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jan 09 10:57 AM
I truly don’t recall how/if I have done this, but where there is a Will there is a How.
Worst case, you could do it via JavaScript.

Run your site and open the source from the browser, locate the control you are looking for and get its ID.
From there, add dynamic code on the Master Page (or whichever file best suits your needs) to Enable/Disable it.

I have done something similar. For instance, I wanted to add an Image to the Mail Merge Write button, but this being a dynamic item being generated from the GroupManager object, my only recourse was to do it via Java script as shown below.

This code is within my Base.Master page:

<script type="text/javascript">

Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(addMMIcon);

function addMMIcon(sender, args)
{
try
{
var muMM = document.getElementById("ToolBar_mnuMailMerge");
if (muMM != undefined)
{
var itmImg = document.getElementById("newWriteItemImg");
if (itmImg == undefined)
{
var oNewItem = document.createElement("IMG");
oNewItem.id = "newWriteItemImg";
oNewItem.src = "images/icons/Send_Write_email_16x16.gif";
muMM.children(0).insertAdjacentElement("BeforeBegin",oNewItem);
}
}
}
catch(e){}
}
</script>

So, if you don’t find an alternate way to disable it, you could always do it via Java Script
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jan 09 11:27 AM
Ok, try this:

NavItemCollection navColl = ((NavItemCollection)(FindControl("NavBar").Controls[0]));
foreach (NavItem ni in navColl.Items)
{
if (ni.ID == "navWelcome") //I am disabling the Welcome Button
{
ni.Enabled = false;
}
}
[Reply][Quote]
Ken Poggensee
Posts: 71
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jan 09 3:42 PM
Ok… I stuffed your snippet in the Page_Load() of the Base.Master.

I can see it stepping through the nav items and when it finds the navWelcome it sets the enabled to false as it should. I see this through the Add Watch for that object in VS but when the client comes up the Welcome left nav item is still there.

What I noticed is it hits the function a couple times during the login but when it hits it the second time the navWelcome enable property is set to true again. Not sure what’s resetting it. I stepped through the trillion other steps it did and could not spot where it was putting it back to true.

Did I tuck it in the wrong spot, or missing something?

…And thanks again Raul for your expert advice. I feel better that I am to the point where I am pretty sure it can be done.

--Ken--


[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jan 09 3:55 PM
Ken:

I wasn't able to test this code as it was just a quick proof of concept and I just relied on the values from the Watch and Immediate windows.
Never the less, I believe that part of the problem is related to the Order of Events.

Each Page has their own "LoadNav" function in which it creates the Navigation bar (check the Account.aspx and/or Contact.aspx).
What is more than likely happenning is that the Page_Load event from the Master file is fired before the Page Load event from the actual Page.

I would suggest you try testing it by loading the same code I provided to the Load event of the ContactDetails.ascx
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jan 09 3:40 AM
Hey Ken, I figured this one out using Javascript (and it does hide the item). Within the file General.js there is a function named populateNavBar(). By editing this you can stop a menu item from being rendered to the user. This function looks at a dynamically arranged array of off the navBar items (if you view source and look for Opportunity.aspx for example you should see the array, something var navBar).

So as an example, within the second for loop in there you could add: "menu.items[j].text != "Welcome")":

|if (menu.items[j].isspacer)
| {
| html.push(templates.spacer.apply());
| }
| else if (menu.items[j].text != "Welcome")
| {
| var tpl = "item" + menu.textimagerelation;
| if (templates[tpl])
| html.push(templates[tpl].apply(menu.items[j]));
| else
| html.push(templates["itemDefault"].apply(menu.items[j]));
| }

Notice the else if:

| else if (menu.items[j].text != "Welcome")

Here I am telling it if the menu.items[j].text is equal to welcome, do not load the item. This stops the Welcome menu from being rendered to the user.

Obviously you can call your own boolean type function and pass the menu.text in, do your logic and return true or false if you want to show or hide the tab.

Your javascript function could be placed in base.master and you could dynamically set your variables using server side code (i.e. check the current user team etc.).

Make sense?

Cheers,
Nick
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jan 09 3:51 AM
To add to that, you can also do a similar thing in the parent for loop to the for loop the above code runs in to hide the entire menu section,. i.e. if you want to hide all of the "Service" nav area...
[Reply][Quote]
Venkatesh
Posts: 72
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jan 09 9:58 AM
I am confused now, Can anyone summarize me with the final solution for hiding Tool bar and Nav bar for the specifict users?
[Reply][Quote]
Ken Poggensee
Posts: 71
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jan 09 3:54 PM
Thanks Nick...
Unfortunately I am on v7.2.2 with this client and that function is not in the General.js. I checked against v7.5 and see exactly what you talking about. I searched VS for PopulateNavBar and didn’t find it stuffed anywhere else either. You know of an equivalent way to do it in v7.2?

So close but yet so far
[Reply][Quote]
Ken Poggensee
Posts: 71
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Jan 09 2:46 PM
Well it’s not elegant, but I figured it out. I stopped trying to get behind the NavBar stuff in 7.2 and looked at what else I could do. I ended up stuffing the code below on the Onload event for all the detail and insert forms that I did not want to show. It simply redirects them to Accounts if they go somewhere they shouldn’t.

My only other issue was with the groups. Like when I did this to Leads, I was able to see the details in the groups. To get around this we are going to manage the releases manually with specific conditions.
-->Unless one of you gurus knows how to tuck something like this in the list view for these selected main views too?

Don’t worry about hurting my feeling if you want to make suggestions on making it a little more elegant.

Well I thought I would share. Hope it helps someone…


--------------------------------------------------------------
string yourVal = string.Empty;
string sql = string.Empty;

Sage.Platform.Data.IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
Sage.Platform.Security.IUserService userService = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string curUserID = userService.UserId;
curUserID = curUserID.Trim();

string connStr = service.GetConnectionString();

using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connStr))
{
conn.Open();
using (System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand())
{
//Check user security for ApproveSPR. Disable radio group and ammount accordingly
sql = "SELECT USERID FROM USERINFO WHERE USERID = '" + curUserID + "' AND DIVISION LIKE '%Distributor%'";
cmd.Connection = conn;
cmd.CommandText = sql;

try
{
object o = cmd.ExecuteScalar().ToString();
if (o != null)
{
this.DialogService.ShowMessage("You do not have access to Leads");
Response.Redirect("Account.aspx");
}
}
catch
{
}
}
}


[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Jan 09 6:29 AM
Hey Ken,

As a suggestion, it may be possible to place all your code in base.master - that way you can cater for the occassion where they go into Leads.aspx and not in detail mode...

Within a Page_Load method you could check requested URL for Lead.aspx etc. if you get a match run the above Lead code. You could do the same for Account/Contact etc...

Havent tried doing this but cant see an obvious reason why it wouldnt work.

Thanks,
Nick
[Reply][Quote]
Ken Poggensee
Posts: 71
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 28 Jan 09 9:15 AM
Groovy... Thanks Nick, sounds a little more elegant. I'll try it.
[Reply][Quote]
Venkatesh
Posts: 72
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 30 Apr 09 4:41 PM
Ken/Nick,

Are you able to hide the NavBar/Tool Bar in slx 7.5? Please share the solution with me, because I am struggling a lot on this.
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 May 09 3:26 AM
I can give you a hint....I spent a while on this so dont want to give it all away

NavBar's are all loaded in general.js, from a Javascript array built on the screen. A bit of splicing on the array can work wonders.....

For Toolbars you can actually add server side in .NET - best places for the code are in dashboard.master and base.master (for welcome.aspx, and all the other pages, if they inherit from base.master). The approach I used was add the main parent Toolbar item in App Architect, then dynamically add the actual Toolbar child items to the parent Toolbar if I decice the user has access, a bit like:

//Sage.Platform.WebPortal.Services.IMenuService mnuSrc = ToolBar.WorkItem.Services.Get<Sage.Platform.WebPortal.Services.IMenuService>();

// if (!hideMenuItem) //They have access, so add the menu item..
// {
// NavItem menuItemMR = new NavItem();
// menuItemMR.Text = "New Menu Child";
// menuItemMR.ID = "mnuSegmentor";
// menuItemMR.Target = "_blank";
// menuItemMR.SmallImageURL = "~/images/icons/Account_Service_Information_16x16.gif";
// menuItemMR.NavURL = "javascript: openApplicationSomeJavascript();";
// mnuSrc.AddMenuItem("mnuParent", menuItemMR);
// }

This example opens a new window to point to another app, so you obviously wouldnt need Target = "_blank" and you would run a direct url as opposed to running a javascript function.

Remember that hotfixes and service packs will update these files so write your code in a way that will make it easy to lift your code out and re-work into the new files.

Enjoy!
[Reply][Quote]
Venkatesh
Posts: 72
 
Re: Hiding NavBar/ToolBar Items at RuntimeYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 May 09 10:09 AM
Thanks Nick, I have handled it in different way in general.js by reading the user info from an xml file and verifying it during runtime. It works fine for me. (It includes Tool Bar too)
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 7/6/2025 9:34:49 PM