AnsweredAssumed Answered

Scripted Find with multiple variables

Question asked by williamrollo on Nov 25, 2015
Latest reply on Nov 27, 2015 by macwombat

I have seen PhilModJunk's post on Scripted Find Examples. However I am a little stuck.

I want the user to be able to select a radio button from each of the two multiple variables that i have.

I want radio buttons as there is only one variable I want them to see, in each of the two fields. EG Car Make and Colour.

I also want a date variable to be added. The result of the found count should appear in a field on the same page layout. I have it working for one variable and the date. But not sure how to use two.. I have butchered my working script by following Phil's script suggestion but am not getting the correct find counts. ... I can supply more info of course but this is just an intro. Script below:

Thank you

 

  • Set Error Capture [ On ]
  • Allow User Abort [ Off ]
  • Freeze Window
  • Commit Records/Requests [ Skip data entry validation; No dialog ]
  • #Validate Dates
  • If [ IsEmpty ( PREF::gFinish ) and IsEmpty ( PREF::gStyle ) ]
  • Show Custom Dialog [ Title: "Warning"; Message: "You need to enter a finish or style or both."; Default Button: “OK”, Commit: “Yes” ]
  • Go to Layout [ “Reports” (PREF) ]
  • Exit Script [ ]
  • End If
  • If [ PREF::gDateStart and IsEmpty ( PREF::gDateEnd ) or PREF::gDateEnd and IsEmpty ( PREF::gDateStart ) ]
  • #Missing both start and end dates
  • Show Custom Dialog [ Title: "Warning"; Message: "You need to have both a start and end date."; Default Button: “OK”, Commit: “Yes” ]
  • Go to Layout [ “Reports” (PREF) ]
  • Exit Script [ ]
  • Else If [ PREF::gDateStart > PREF::gDateEnd ]
  • #Start date greater than end date
  • Show Custom Dialog [ Title: "Warning"; Message: "The end date must be on or after the start date."; Default Button: “OK”, Commit: “Yes” ]
  • Go to Layout [ “Reports” (PREF) ]
  • Exit Script [ ]
  • End If
  • If [ IsEmpty (PREF::gDateStart) and IsEmpty (PREF::gDateEnd) ]
  • #No date specified, find all
  • Show Custom Dialog [ Title: "Warning"; Message: "Please enter date range."; Default Button: “OK”, Commit: “Yes” ]
  • Go to Layout [ “Reports” (PREF) ]
  • Exit Script [ ]
  • Else
  • Freeze Window
  • #Find by specified date range.
  • Go to Layout [ “Report orders by type” (INVOICEITEMS) ]
  • Set Variable [ $Style; Value:PREF::gStyle ]
  • Enter Find Mode [ ]
  • Set Field [ INVOICEITEMS::fk_order Date; PREF::gDateStart & ".." & PREF::gDateEnd ]
  • Loop
  • Set Variable [ $K; Value:$K+1 ]
  • Set Field [ INVOICEITEMS::Fender Style; GetValue($Style;$K) ]
  • Exit Loop If [ $K ≥ ValueCount($Style) ]
  • New Record/Request
  • End Loop
  • Set Error Capture [ On ]
  • Perform Find [ ]
  • Set Field [ INVOICEITEMS::Fender style Find; Get(FoundCount) ]
  • End If
  • If [ Get (FoundCount) = 0 ]
  • #No records found
  • Show Custom Dialog [ Title: "Message"; Message: "No orders found within the specified date range."; Default Button: “OK”, Commit: “Yes” ]
  • Go to Layout [ “Reports” (PREF) ]
  • End If
  • Go to Layout [ “Reports” (PREF) ]

Outcomes