Restricting Value List When Duplicating a record
I like this forum!
I have multiple text fields in a layout that display the value of a list. When duplicating a record I want these fields to clear out. How can this be done?
Well, you can get as complicated as you need, but it's basically straightforward.
Enter Browse Mode
SetField (FirstField ; "" )
SetField (SecondField ; "" )
SetField (ThirdField ; "" )
SetField (LastField ; "" )
That should do it. It shouldn't matter that the field is an edit box, a drop-down list, a radio button, or anything else (if I understood your concern correctly).
Personally, I remove the "duplicate" function from the menu and require users to use a script that performs a duplication and clears the fields that I want to clear (using the Set Field script step.)
I'd assume, though, that the same thing could be accomplished by setting the fields to Auto-Enter a value of "".
If you need either of those spelled out in more detail, let me know.
I am using FM10, where do I find this "OnRecordLoad" script step?
Sorry - I misunderstood. I thought you wanted fields that utilized value lists to clear. Instead, it sounds like you want the value list to clear?
In that case, we need more information. Where is the value list drawing its information from? A related table? A hard-coded list?
If it's a related table, what is the relationship?
No you did not misunderstand me, it must be me who's confusing.
I do want the field that utilizes the value list to clear when duplicating a record.
I did the script like you suggested and the fields will not clear. I was using FMp 9 and upgraded to FMp 10.. In fact, the only one field that this setfield script works with is a field that was created after I upgraded to FMp 10. I have no idea if this makes a difference or not but this setfield script will not work on the fields that was created in FMp 6, even before I upgraded to FMp 9.
Sorry for my confusion. :)
Hmmmm. Any chance you have the field set with a validation requiring it to be non-empty? Or that the user running the script doesn't have access to editing data in those fields?
That's all I can think of that would cause the SetField script steps to fail.
Anyone else have a thought?
Okay, Call me what you want but I figured out what I was doing wrong.
I did have the script written correctly. However, I was using the duplicate request in the command bar instead of creating a sript button to trigger this sript.
So you did have it correct the first time.
Hehe. We've all done worse. I've done the "Stupid, Stupid, Stupid" bang head on desk thing twice this week, myself.
Have a great weekend, buddy!
You can use the Duplicate menu command along with a triggered script as I mentioned (if you prefer that to a button).
You find it in the layout options under Script Triggers. Select "OnRecordLoad" and tell it to run the script you just created and voila.
Retrieving data ...