Link to home
Start Free TrialLog in
Avatar of tashsmith
tashsmith

asked on

Setting a group of field values when document is saved

I have two groups set up controlling access to a particular database. These groups are called "ContentEditors" and "ContentAuthors".

When one of the users  in either of these groups save a document, I would like to set a number of fields to the value "Waiting", regardless of their current values when a document is saved.
These are editable fields:-

p1
p2
p3
p4

This should not happen if the user is NOT in either of the two groups..

Any tips on how this can be done would be greatly appreciated..

Thank you
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

What's the difference (right-wise) between those groups? What can a ContentEditor do more than a ContentAuthor? But that's not he question...

The usual solution is to give a group a role as well, so you can use @UserRoles to find out a user's rights:

    @If(@IsMember("ContentEditors"; @Userroles);
        @Do(
            @Setfield("p1"; "Waiting");
            @Setfield("p2"; "Waiting");
            @Setfield("p3"; "Waiting");
            @Setfield("p4"; "Waiting")
        )
    )
Avatar of tashsmith
tashsmith

ASKER


Right OK, the @UserRoles solution does seem more sensible. Both these groups have the role of 'publisher', which should govern this behaviour.

Would this be the way to deal wth this?

@If(@IsMember("[publisher]"; @Userroles);
        @Do(
            @Setfield("p1"; "Waiting");
            @Setfield("p2"; "Waiting");
            @Setfield("p3"; "Waiting");
            @Setfield("p4"; "Waiting")
        )
    )

thks
Exactly. Note that member checking in Formula language is case-sensitive. For free is

@If(@IsMember("[publisher]"; @Lowercase(@Userroles));
        @Do(
            @Setfield("p1"; "Waiting");
            @Setfield("p2"; "Waiting");
            @Setfield("p3"; "Waiting");
            @Setfield("p4"; "Waiting")
        );
        ""
    )

Note: additional line with ""
OK,  I have more than one form in the database design, is there somewhere globally that this can be placed?
BTW the user gets a prompt to save on exit (esc) , we do not have a save button as such
> When one of the users  in either of these groups save a document ...
Then how do they save? There is Esc, and then Yes, or Ctrl-S for save.
You say you have more forms, but are they doing exactly the same?

Please explain the desired functionality, as my assumptions are often wrong...
We have a number of forms, all of these forms will be used by documents  and saved by people who will either, use CTRL-S of ESc and be prompted to Save.
In all cases this should work.

@If(@IsMember("[publisher]"; @Lowercase(@Userroles));
        @Do(
            @Setfield("p1"; "Waiting");
            @Setfield("p2"; "Waiting");
            @Setfield("p3"; "Waiting");
            @Setfield("p4"; "Waiting")
        );
        ""
    )

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What I meant by this should work, was that the script should run on all forms where the user has the role 'publisher'.
I have tested it on one form and it works very well.

I will add it to the QuerySave events of all forms that require it.

Thanks very much
Welcome :)

Do all forms have the same fields? Are those forms very similar? Do you use subforms? If that's the case, you could add the formula to the QuerySave of a subform that you use in all forms.
Yes I have added to the subform that holds the fields in question. All works a treat!!