Scripting

  • 1.  Trying to create a button script to delete records

    Posted 09-11-2015 11:55
    Trying to create a button script to delete records. Specifically, Bill Option Header & Bill Option Detail records for an entire Bill # & Bill Option Category. This is running on Advanced, so I believe that is creating some issues as well. We have come at this from 2 different angles; neither are working. We tried one method (Lwa_Deletebomoptiondetail.vbs) where we prompt the user for the data, open a connection, run a SQL statement, & then run delete. However, I feel like this is mixing methods & not sure if it works together or not. We tried a bunch & then commented a bunch out, etc. I tried placing it on the Bill Maintenance Header panel & it does nothing; I am assuming because it is not the current oBusObj. I then placed it on the Bill Option Header panel & we can get it to sometimes work & sometimes clear all records for that Bill, regardless of the Bill Option Category. I believe it is because we are trying to delete a record using oBusObj & it doesn't like to delete itself?? I tried going another way (Lwa_Bm_Delete_Billoptions.vbs), but I always get an oSession error & don't know why. Another issue is this is MAS200, so I don't think I can use those input boxes, correct? So, if I run it from Client, I get the error, but if I run it from Server, I get the input box errors. If I place the button on the Bill Option Header panel, I can bring in the fields I need so I don't need to prompt the user, but then I am back to the current oBusObj issue, I think. Which way should we be headed?? Or are we completely out in left field?

    Attachment(s)



  • 2.  RE: Trying to create a button script to delete records

    Posted 09-11-2015 12:43
    If you want to pursue the second approach, my workarounds for the lack of Input Boxes is sometimes a UDF on the screen (as a substitute for an Input Box) next to a Go button, which would run the UDS. The other approach I've used is to dump details into a UDT and then run a BOI script that references the UDT. The first approach is much cleaner :).


  • 3.  RE: Trying to create a button script to delete records

    Posted 09-12-2015 01:58
    Dana you can use an InputBox on MAS 200. You and Steve both were AWOL for Intermediate class in NOLA. I covered that :disappointed: Something like this: 1 Create a UDF on Bill Option Header to temporarily store your OptionCat, say UDF_OPTIONCAT. You don't even need to put it on the screen but do it anyway to begin with so you can see the flow. 2) Create a button and place it on DOPTION (Option Bill Maintenance). Set it to MS Script and click to Execute Script on Client. Click the Select Variables To Be Passed To Script button. Move BM_BillOption_bus_UDF_OPTIONCAT$ to the right pane and click OK. You must also click the Return checkbox. Later do one more thing change the button state so it is enabled as soon as you get into the Options screen (not when you select an Option Category). Search on KEYFIELD I posted how to do that in another reply. Put your InputBox in this script then at the end set UDF_OptionCat the old-fashioned way: OptionCat = InputBox (""Enter the Option Category to remove."") 'Valid OptionCat values are 1 - 9 If Len(OptionCat) = 1 and IsNumeric(OptionCat) and OptionCat > 0 Then BM_BillOption_bus_UDF_OPTIONCAT = OptionCat Else MsgBox ""Try again Charlie."" End If The above will implicitly do a SetValue() on UDF_OptionCat meaning: 3) Create a Column Post-Val script on UDF_OptionCat. Do your Deletes and object coding in there.


  • 4.  RE: Trying to create a button script to delete records

    Posted 09-12-2015 02:19
      |   view attached
    The other problem you mention stems around BM_BillOptions_bus being a child obj of BM_Bill_bus but not as a data source. You must set BM_Bill_bus first (for BM_BillHeader) with the BillNo + Revision. The good news is when you get into the Options screen, it has been set for you and has also been passed into 2 parts of the 4-part key of BM_BillOptionHeader that is you already have a partial key - no need to SetBrowseFilter). Now just use oBusObj (BM_BillOptions_bus) to loop through the Option Header table, check if the Option Category matches the one from the InputBox from the button script. If so delete the Option Header rec and corresponding detail recs. Attached is what your Column Post-Val of UDF_OptionCat script could look like.

    Attachment(s)



  • 5.  RE: Trying to create a button script to delete records

    Posted 09-14-2015 09:33
    Thanks @AlnoorCassim. I am going to try this out!


  • 6.  RE: Trying to create a button script to delete records

    Posted 09-15-2015 07:28
    @AlnoorCassim this is working great! Except for the KEYFIELD part. I found the other post, but when I go to BM_Options.M4L in DFDM there is no BT_LINK_ record. I tried it on some other BT records in the DMAIN, but it didn't help. I need to key in an Option Category & an Option Code for the button to become available. Is it because there are multiple fields? I think they could live with filling these in to get the button to become available. Just wondering if I am missing something else or if this screen is just different or more complex. Thanks again! You are the best!!


  • 7.  RE: Trying to create a button script to delete records

    Posted 09-15-2015 08:06
    KEYFIELD must not be working as expected because it's a multipart key. You could remove KEYFIELD so there is no button group association at all.