Scripting

  • 1.  hi all - customer has certain invoice batches th

    Posted 11-07-2017 09:44
    hi all - customer has certain invoice batches that are imported where they need to check each invoice in the batch for drop ships based on some warehouse and other criteria. I have the 'individual' invoice script working (ie fires on the Table PreTotals for each invoice), but this would require them to open the batch and visit each invoice. Anyone have a snippet of code for looping through all the invoices in a batch? I was hoping to add a button to the S/O Invoice Data Entry Batch screen, but looks like that screen is unable to be modified. Next best idea was to add a button script to the invoice screen, where they would open the batch and click the button on the first invoice of the batch and have it loop through all the batch contents and update accordingly. I am struggling to get the batch entry handles to move next etc on. any help is appreciated! Thanks, Marc


  • 2.  RE: hi all - customer has certain invoice batches th

    Posted 11-07-2017 09:51
    When the Table PreWrite fires off, it will run the PreTotals as well. Same should happen on an import. PreTotals would NOT get fired off in the situation where say you are importing into existing invoices and updating a single field like the Header comment or email address or somethign. IOW, as long as you are adding / editing / deleting lines in your import, your PreTotals should fire off. Just make sure to condition any UI like MessageBox or ProgressBar to not run if Left(oSession.StartProgram,4)=""VIWI


  • 3.  RE: hi all - customer has certain invoice batches th

    Posted 11-07-2017 09:51
    is the criteria you are checking for individually added by hand after the invoice has been imported? if not, why not use the table pre-write event so your script will fire when imported through VI


  • 4.  RE: hi all - customer has certain invoice batches th

    Posted 11-07-2017 10:04
    Guys - thank you for the insight. So here i was testing it on an existing batch, but not trying to import over and over again. Sheesh! Sounds like the import will fire it if its in the pretotals so the importing part will work automatically. Excellent! Now if they want to run the script on a Manually entered batch, still thinking i want to add a button to the invoice entry screen that loops through all the details of the batch. is that possible?


  • 5.  RE: hi all - customer has certain invoice batches th

    Posted 11-07-2017 10:33
    `Set oLines = oSession.AsObject(oBusObj.Lines)` `retVal = oLines.MoveFirst()` `do until oLines.EoF ` `' do stuff` `retVal = oLines.MoveNext()` `loop ' oLines`


  • 6.  RE: hi all - customer has certain invoice batches th

    Posted 11-07-2017 21:05
    Bored and had time to kill, so here is a tip I learned from Alnoor. If you need a button to be enabled even when a record is not loaded, then configure the button as a DDE link instead of an MS Script link. Use the ""Edit Script"" button and then in the ""Program"", enter ""*PERFORM"", in the the ""Topic"", enter the path to a text file containing provideX code. This has a slight drawback as you can't code your solution in VBScript as I've not yet figured out how to dynamically point the button to a VBScript file using the button's Tag$ variable, it seems the CMWSDA program will always look at the M4L record for the button to determine the script configuration. At least that is how it is behaving in my v2015 VM. Anyway, provideX isn't that bad and I've attached a pvc file showing how you could accomplish this, complete with a progress bar and also checking if the user is on a record, you wouldn't want to move from the record if they haven't saved a bunch of changes yet. On another note, if you absolutely want to use VBScript, then you could use another approach to enable a MS Link button even when a record is not loaded. This requires a Post-Load UI event script (an additional dependency). I've attached a VBScript called enable_buttons.vbs. This file allows you to specify the groups and and controls using arrays and then looping through them and executing the appropriate commands. If you only want to enable a single button, then look at the enable_button.vbs file for a much simpler example.

    Attachment(s)

    zip
    enable_button.zip   364 B 1 version
    zip
    enable_buttons.zip   531 B 1 version
    pvc
    LoopThroughBatch.pvc   2 KB 1 version