Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / August 2005

Tip: Looking for answers? Try searching our database.

JScript Programming .... help required

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adam Harding - 24 Aug 2005 11:52 GMT
Working in JScript

I am VERY new to programming let alone in JScript but understand some of the
Jargon.  I am looking to write an On Load event that does the following:-

If User is assigned Role 1 then switch view to View 1 and set default to
View 1
If User is assigned Role 2 then switch view to View 2 and set default to
View 2
Is user is assigned Roel 3 then switch view to View 3 and set default to
View 3

I know it is possible from looking at all the other posts but don't know
exactly how to do it myself.

My first Role is equivalent to OurDomain\Everyone
My second role is equivalent to a collection of individuals defined in
Infopath and hence also members of OurDomain\Everyone
My third role is equivalent to OurDomain\MyDepartment who are also always
members of my first role but sometimes also the second role.  

I would like the roles to cascade down from Role 3 to Role 2 to Role 1 on
this event.

I would very much appreciate any help anyone could give as i am out of my
depth with this one.

Thanks in advance

Adam
Scott L. Heim [MSFT] - 24 Aug 2005 13:51 GMT
Hi Adam,

You can do most of what you need simply using Rules - will this not work
for you? What is the reason for changing what View becomes the "Default?"
Using Rules to check a person's role and then switching Views based on
their role is quite common but changing which View becomes the default is
not a request I have seen before. Can you shed some additional light on
this?

Thanks!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
Adam Harding - 24 Aug 2005 15:30 GMT
Scott

Nice to hear from you again

Rules do not work due to the overlap of membership of the groups.

Reason for setting default is that certain actions close the form and open
up a new one i think it would be quite useful to have their form as the
default.  PS I saw a post from Brisk in reply to one of my queries regarding
this and he said that is what he uses the code to do, so i think it is a kind
of failsafe.

Cheers Adam

> Hi Adam,
>
[quoted text clipped - 11 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights
Scott L. Heim [MSFT] - 24 Aug 2005 17:03 GMT
Hi Adam,

Let's start with this and see how close we get to what you need:

- Open your form in Design View
- From the Tools menu choose Programming and then select: On Load Event -
you should see the following:

function XDocument::OnLoad(eventObj)
{

}

- Add this code between the braces:

    var strCurrentRole = XDocument.Role;
   
    if(strCurrentRole == "Role 2")
    {
        XDocument.ViewInfos("View 2").IsDefault = true;
    }

** NOTE: You will need to change Role 2 to one of your Role names and View
2 to the appropriate View name.

- For now, let's test with just this one role - does it switch properly
when the user opens the form? If so, we will need to add additional logic
to this sample to include the other roles.

Thanks,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.