Scripting

Expand all | Collapse all

I am pretty sure I'm making this way more difficul

  • 1.  I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 10:28
    I am pretty sure I'm making this way more difficult than necessary...I am trying to create a script that will ultimately set some form criteria in Sales Order Invoice printing. I have to either offer the batch selection window or pick that up from invoice data entry (if the script ends up being launched by a button in invoice data entry) and then set the form code, print invoices already printed CB and the paperless delivery options. I have found some helpful script pieces out here but I can't seem to get the Invoice Printing UI to pop up and pick up these values I am trying to set. Has anyone had success with this?


  • 2.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 10:37
    We had a sample script in one of the classes that might help.


  • 3.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 10:38
    QuickPrintSOromPOEntry.txt


  • 4.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 11:20
    Thanks Nicole! I have definitely been utilizing those scripts. I think I am much closer after your help, but do you happen to know where I can determine the correct names of the Invoice Printing screen fields? I need to trip Print Invoices Already Printed but I'm unable to find what that field is really called.


  • 5.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 11:38
    I believe the quick print method doesn't rely on whether or not the invoice is flagged as printed


  • 6.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 11:39
    Try opening the ""SO_InvoicePrinting.M4L"" file in DFDM that will get you the field names. The field name is called PRINTINVOICESPRINTED. Though I'm not sure how you would put it in the script maybe try retVal = oReport.SetValue(""PrintInvoicesPrinted$"", ""Y"")


  • 7.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 11:39
    @MichaelNottoli thats true


  • 8.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 13:21
    Thanks for your help. This process seems to go out of whack because of the batch number selection. Invoices print like you would expect but it is grabbing all the invoices from every batch. Boo.


  • 9.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 14:20
    Are you doing this thru external BOI? Do you know the Batch No ahead of time? Here's an old example snippet of using batches: 'Instantiate a S/O Invoice business object oSEC = oSS.nSetProgram(oSS.nLookupTask(""SO_Invoice_ui"")) Set o = oScript.NewObject(""SO_Invoice_bus"", oSS) ' Check the BatchEnabled property to determine if batches are enabled IF o.nBatchEnabled = 1 Then ' Call the SelectBatch method to open an existing batch or create a new ' batch. This method takes the Batch Number as a single argument. If ' Batch Number is null, a new batch will be created and the new batch ' number will be returned in the Batch Number argument. ' Example: 'BatchNo = <<Existing BatchNo>> or BatchNo = """" for new batch 'o.nSelectbatch(BatchNo) ' Call the SelectNewBatch method to create a new batch and set the Private ' Batch flag and Batch Comment. This method takes 3 arguments: Batch ' Number (set to null), Private Batch set to ""Y"" or ""N"", and the Batch ' Comment. The new batch number will be returned in the Batch Number ' argument. Example: BatchNo = """" PrivateFlag = ""Y"" CommentText = ""This is a comment"" r = o.nSelectNewBatch(BatchNo, PrivateFlag, CommentText) End If


  • 10.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 14:34
    Hi Alnoor! At this point, I'm trying to set some defaults on the SO Invoice Printing Screen based on form code. Whether that is done by clicking a button from invoice data entry that loads the print invoices already printed and changes the paperless output to ""email and print"" then that would work, otherwise external BOI is good also, just whatever might work at this point. If it comes from invoice data entry, then the batch number would be known. it doesn't even have to actually print the invoices from the script, just bring up the Invoice Printing UI and set these defaults.


  • 11.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-01-2015 23:43
    Hey Breck I get it now. You're trying to pop the UI for Invoice Printing and set specific report options at the same time (like you said at the very beginning - should've read that sooner). Unfortunately I don't know how to pop the UI here :anguished: because both the Process() method and InvokeProgram() require passing in the key. When you do oReport.SetKey() you can get the multi-part key via RptKey=oReport.GetKey() But when you send it, the report UI would attempt to load but then bark at you about there not being a Template set. This would be a good one for Sage City assuming the Sage engineers are watching. I thought you were trying to do the actual Print / Preview without a UI like the class example. Now even that is harder with invoices than quick printing a sales order but you can do oReport.SelectBatch(batchNo) to set the batch No.


  • 12.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-02-2015 00:00
      |   view attached
    One more thing. If you don't mind not popping the UI and just printing with those options set, maybe you can the @MichaelNottoli post example of using InitReportEngine(). You may not need external BOI like his example. Instead of trying to use oReport to write the report selection pieces to memory, you can: ` oReport.SelectReportSetting(myRptSetting) oReport.SetReportOptions(optionsString) 'optionsString would be set prior to this and look similar to the screen shot attached but use the separators with the double double quotes like you see in Michael's example oReport.InitReportEngine() oReport.SetTemplateDesc(""PLAIN"") 'not correct syntax but something close to this oReport.ProcessReport(""PRINT"") 'or oReport.ProcessReport(""PREVIEW"") `


  • 13.  RE: I am pretty sure I'm making this way more difficul

    Posted 07-02-2015 07:49
    Thanks so much for all your help! After staring at it for days I had hit the wall. I will see if the customer is okay without the UI and if not, I'll tell them to just be careful about the print options they have selected! I appreciate your time and direction!