1 2 Previous Next 19 Replies Latest reply on Jan 30, 2013 10:16 AM by lorrainem

    How can I conditionally change a field attribute?

    lorrainem

      I want to prevent input into a fileld which has a value list associated with it depending on the value in another field. Specifically, if another field contains a valid date then I do not want to allow any modifications in the field which has the value list associated with it. I don't want the user to be able to change to another value in the value list. How can I do this? Can I? Thanks!

        • 1. Re: How can I conditionally change a field attribute?
          christinesephton

          I would do this with Script Triggers.

           

          First Create a Self Join Relationship:

           

          Date Field=Field Using Date Field in Value List

           

          Then Create a script:

           

          • Allow User Abort [ Off ]
          • Set Error Capture [ On ]
          • If [ Get(ScriptParameter)="Enter" ]
          • Set Variable [ $$value; Value:Test::DateField ]
          • Set Variable [ $$count; Value:Count(Self Join::DateField) ]
          • Else
          • If [ $$count>0 ]
          • Set Field [ Test::DateField; $$value ]
          • Set Variable [ $$value; Value:"" ]
          • Set Variable [ $$count; Value:"" ]
          • End If
          • End If

           

          Then Select the Date Field and create a script trigger for "OnObjectEnter", select the script above and in the ScriptParameter Area type "Enter"

          Then Select the Date Field and create a script trigger for "OnObjectExit", select the script above and in the ScriptParameter Area type "Exit"

           

          This should place the same value back into the Date Field of the other field is using the value.

           

          Thanks,
          Christine

          • 2. Re: How can I conditionally change a field attribute?
            lorrainem

            Well I can set privileges for a value list but I want to "conditionally" change the attribure of the field that uses the value. I don't think I can modify Privilege Set values conditionally. What I want to do is modify the field attribute for the field  which uses the value list to prevent input into that field conditionally - i.e. if I have a date in another field. I don't think I can do that with Privilege Sets.

            • 3. Re: How can I conditionally change a field attribute?
              christinesephton

              I revised my answer to a solution that better fits your needs.

              • 4. Re: How can I conditionally change a field attribute?
                lorrainem

                Christine,

                   I am not really sure what you are doing in the scipt you wrote but I have a feeling it does not address my problem. I have field A which is associated with a list of names. The user can select any name from the list and update the value of field A. But now my user does not want to allow any changes to the Field A (via choosing a value in the value list) when another field, Field B, has a date in it. Once I see a date in field B I want to Protect field A so that the user cannot change the value in that field. I'm not sure how your script accomplishes that?

                • 5. Re: How can I conditionally change a field attribute?
                  christinesephton

                  Sorry I miss understood what you wanted to accomplish.

                   

                  You would not need to do a Self Join and instead would edit the script above to the following:

                   

                   

                  • Allow User Abort [ Off ]
                  • Set Error Capture [ On ]
                  • If [ Get(ScriptParameter)="Enter" ]
                    • Set Variable [ $$value; FieldA ]
                  • Else
                    • If [ Not IsEmpty(FieldB) ]
                      • Set Field [FieldA:Value:$$value]
                      • Set Variable [ $$value; Value:"" ]
                    • End If
                  • End If

                   

                  Then set up the script triggers as indicated above on FieldA.

                  • 6. Re: How can I conditionally change a field attribute?
                    lorrainem

                    Hmm.. This looks like it would work. I'll give it a try. The only thing I don't like about this is that it would allow the user to think they were changing the value but I would keep putting back the original value if I am understanding it correctly. I would prefer if if I could just Protect Field A if field B had a date in it. Using your solution above what scipt trigger would be best do you think - OnRecordCommit maybe? I have not used script triggers before.

                    • 7. Re: How can I conditionally change a field attribute?
                      lorrainem

                      I don't think OnRecordCommit will work. I need to know the status of the two fields when I come into the layout so maybe OnLayoutEnter I need to determine if a change to field A is allowed. Then OnRecordCommit I check to see if it has changed and "Un" change it before the commit if change was not allowed. Anyway, I'll give that a try and see if it gets me what I want. Although I would still prefer being able to protect field A if  a change to it was not allowed. If someone can tell me how I can do that it would be appreciated.

                      • 8. Re: How can I conditionally change a field attribute?
                        christinesephton

                        You can put the script trigger directly on the field itself.

                         

                        Select the Protected Field and create a script trigger for "OnObjectEnter", select the script above and in the ScriptParameter Area type "Enter"

                        Select the Protected Field and create a script trigger for "OnObjectExit", select the script above and in the ScriptParameter Area type "Exit"

                         

                        The second solution would be to just put a Script Trigger that will advance them to the next field if they try to select/enter the field, and it already has a value.

                        Its completely up to you.

                        • 9. Re: How can I conditionally change a field attribute?
                          lorrainem

                          Chrsitne,

                             

                          This is what I eneded up doing and it seems to be working ok so far.

                           

                          First I used an OnObjectEnter as you suggested: it just saves the current value of the Processor field.

                           

                          Set Error Capture [on]

                          Set Variable [$$OriginalProcessorValue;Value:FOIA::Processor]

                          Exit Script[]

                           

                          Then if the field is modified I use OnObjectModified. If the date field (here Response Mailed Final) contains a date (i.e. > blank)  I send an error message that the Processor field can't be changed and I revert the field back to it original value.

                           

                          Set Error Capture [on]

                          If [FOIA::Response Mailed Final > " "

                              Set Field [FOIA::Processor; $$OriginalProcessorValue]

                              Show Custom DIalog ["Processor May Not Be Changed"; "This case is CLOSED. No change is allowed to the Processor."]

                          End If

                          Exit Script []

                           

                            Thanks for your help. It helped me narrow down to a clean concise solution!

                          • 10. Re: How can I conditionally change a field attribute?
                            christinesephton

                            The reason I did the OnObjectExit is so it does not hold the value for the next record.  Otherwise it is possible that it will enter the wrong value back.  Just being careful to clear the variable.

                            • 11. Re: How can I conditionally change a field attribute?
                              lorrainem

                              Ok. Thanks. Will play around with it some more to see if I can break it.

                              • 12. Re: How can I conditionally change a field attribute?
                                Oliver_Reid

                                Here a way (attached)

                                1 of 1 people found this helpful
                                • 13. Re: How can I conditionally change a field attribute?
                                  lorrainem

                                  Oliver,

                                     This is a cool solution. I like it because I don't have to display any error message and I don't give the user the option to even change the field if a date is filled in. I am going to try this in my application!   Thanks very much!

                                  • 14. Re: How can I conditionally change a field attribute?
                                    laguna92651

                                    Hi Oliver

                                    Where are you using the "next field" script? I can't seem to find it referenced anywhere. Thanks

                                    1 2 Previous Next