JScript Programming .... help required

A

Adam Harding

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
 
S

Scott L. Heim [MSFT]

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.
 
A

Adam Harding

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
 
S

Scott L. Heim [MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top