January 20, 201511 yr If i have a checkbox field. How can i make a script that goes through the checkbox selections and creates a new record for each selection i choose. Example Checkbox field... A B C If I check A and C I want to have a script that goes to a new table and creates a new record for each selection New Table Record A Record C Thanks again for the help!
January 20, 201511 yr I assume the checkbox is a global field. Script could look something like this pseudo script: THIS IS FOR A FIND. PLEASE SEE FOLLOWING SCRIPT TO CREATE NEW RECORDS If [ IsEmpty ( table::gCheckbox ) ] Show Custom Dialog [ Message: "Please enter a value"; Buttons: “OK” ] Exit Script End If # Enter Find Mode [ ] Loop Exit Loop If [ Let ( $count = $count + 1 ; $count > ValueCount ( table::gCheckbox ) ) ] New Record/Request Set Field [ yourDataField ; GetValue ( table::gCheckbox ; $count ) ] End Loop Set Error Capture [ On ] Perform Find [ ] If [ not Get ( FoundCount ) ] Show Custom Dialog [ "No records found." ] End If However, you can also use this checkbox set to GTRR ( Go To Related Records) if you make it the parent key to the table holding the records (even if it is this same table, known as a self-join). You can join this global checkbox to the field, represented in this script as 'yourDataField'. added End If in the script Edited January 20, 201511 yr by LaRetta
January 20, 201511 yr LaRetta, I think the OP wants to create new records from a value list, not find any … btw, you could exit the request loop by using ( Get RequestCount ).
January 20, 201511 yr Ooops! Thank you, Oliver! If [ IsEmpty ( table::gCheckbox ) ] Show Custom Dialog [ Message: "Please enter a value"; Buttons: “OK” ] Exit Script End If # Go To Layout [ your new table layout where records should be created ] Loop Exit Loop If [ Let ( $count = $count + 1 ; $count > ValueCount ( table::gCheckbox ) ) ] New Record/Request Set Field [ yourDataField ; GetValue ( table::gCheckbox ; $count ) ] End Loop
January 20, 201511 yr btw, you could exit the request loop by using ( Get RequestCount ). I hadn't seen your add-on ... yes you can. You can even use Get ( RecordNumber ) and Get ( FoundCount ) instead as: Enter Find Mode [ ] Loop Exit Loop If [ Get ( FoundCount ) > ValueCount ( global checkbox ) ] Set Field [ dataField ; GetValue ( global checkbox ; Get ( RecordNumber ) ) ] New Record/Request End Loop Perform Find [ ] ... Many script steps in FileMaker are interchangeable in this way depending upon the mode you are in at the time. :-) This is in response to the FIND script originally posted and not the New Record script posted after. Caveat: You must make sure you are in Find mode or you will create new records and Get ( RecordNumber ) and Get ( FoundCount ) will be based upon your actual data and not the value count of the checkbox. Not good. Normally, using a variable when you loop is standard practice.
January 20, 201511 yr Hi ets, If i have a checkbox field. How can i make a script that goes through the checkbox selections and creates a new record for each selection i choose. Example Checkbox field... A B C If I check A and C I want to have a script that goes to a new table and creates a new record for each selection New Table Record A Record C I’m a little bit curious as to why you are creating new blank records based on your Record A and C? Tell us what the purpose is of these new blank records? Lee Edited January 20, 201511 yr by Lee Smith change my wording a little
January 20, 201511 yr Hi Lee, The new records are created based upon the checkbox field results (only containing A and C) and not based upon the value list of the checkbox. ... the OP wants to create new records from a value list, not find any … I believe that eos meant checkbox field and not value list here. The script provided uses the checkbox field and not the value list. :-)
January 20, 201511 yr I understood that part. I don’t understand the new records with a single entry of A or C.
January 20, 201511 yr This comes up often for creating join records such as in a Survey ... EXAMPLE Questions -< Responses >- Answers Creating responses to a Question, using a value list of potential Answers. Provide a User Response checkbox then create the join records from the selections. In this example, we would also include the current table's primary key. But you are correct in that we do not know how this will be used.
January 20, 201511 yr Questions -< Responses >- Answers Oh, that's clever - wouldn't have thought of that.
January 21, 201511 yr I believe that eos meant checkbox field and not value list here Just to be clear: I meant a value list (as in: a list of values, i.e. the current field contents – which of course could just be a single-value value list) – not the value list (the pre-defined one that the field is formatted with). This comes up often for creating join records such as in a Survey ... EXAMPLE Questions -< Responses >- Answers Any join table record creation - e.g. roles, line items, StudentsInClass – where you select from a list of parentsB – actors, products, students – to add them to parentA – a movie, an invoice, a class …
January 21, 201511 yr It was the use of a join table as responses to a test or survey I hadn't thought of.
Create an account or sign in to comment