Email pdf of purchase order directly from workflow

Hello, I am on v6.5 p31.

My topic is very similar, if not identical to http://sagecity.na.sage.com/support_communities/sage_erp_x3/b/sageerp_x3_product_support_blog/archive/2015/05/18/how-to-setup-a-workflow-to-email-invoice-to-customer-contact, , but the details are however different. 

I have a workflow rule set up to email certain individuals within our company when a PO is made and meets certain criteria. 

I would like to attach to this email a PDF of the purchase order. Does anyone know if this is possible? 

I was hoping that I wouldn't have to write custom code, but could simply use the logic shown at the bottom of the Message Tab of the workflow. 

Thank you very much, 

-Eliot 

  • 0
    See "Workflow to automate sending crystal reports"
  • 0 in reply to Israel Braunfeld
    Israel,
    Thank you for the quick response.
    However, I do not have 'AIMP3' as an available action.

    I am very new to creating workflow notifications and really don't have any experience with actions.
    Slowly learning about this great big X3 world.

    -Eliot
  • 0 in reply to Eliot Paisley
    Hi Eliot,

    IMPRIME is the action and AIMP3 is the actual source code. Israel is showing how to leverage the IMPRIME action to build the file in that specific technique. If you follow that technique you'll still need to call meladx, an executable in the X3 stack responsible for sending mail, or a program that calls is meladx for you.

    Actions are pretty powerful in X3, and we have some examples in the online help. Not sure which version you are on, but you can take a look there. The basic idea is that when an entry point occurs, you can catch it in your own SPE program by interrogating the action variable, and then run your code however you like.

    Hope this helps some.
  • 0 in reply to Delamater

    Hi Delamater,

    I have similar kind of requirement.  

    Default Purchase Order Workflow is enabled. After the PO Creation ,workflow mail will trigger to users for the signature,Up to this is default functionality. Additionally  i needs to attach the PO report PDF along with that mail. 

    As advised above i created a action on the PO Workflow  and call the subprogram to create the pdf on workflow start. Below is my code:

    Subprog PRINTPO()

    Local Integer NBPAR_MAX:NBPAR_MAX=250
    Local Char TBPAR(250)(1..NBPAR_MAX)
    Local Char TBVAL(250)(1..NBPAR_MAX)
    Local Char RETVAL

    Local Integer I(10)
    Local Integer J(10)

    infbox "po"+num$([M:POH0]POHNUM)

    TBPAR(1)="commandedeb":TBVAL(1)=[M:POH0]POHNUM
    TBPAR(2)="commandefin":TBVAL(2)=[M:POH0]POHNUM
    TBPAR(3)="fournisseurdeb":TBVAL(3)=[M:POH0]BPSNUM
    TBPAR(4)="fournisseurfin":TBVAL(4)=[M:POH0]BPSNUM

    TBPAR(5)="sitedeb":TBVAL(5)=[M:POH0]POHFCY
    TBPAR(6)="sitefin":TBVAL(6)=[M:POH0]POHFCY

    TBPAR(7)="signedeb":TBVAL(7)="0"
    TBPAR(8)="signefin":TBVAL(8)="5"

    TBPAR(9)="datedeb":TBVAL(9)=[M:POH0]ORDDAT
    TBPAR(10)="datefin":TBVAL(10)=[M:POH0]ORDDAT

    TBPAR(11)="devdeb":TBVAL(11)=[M:POH1]CUR
    TBPAR(12)="devfin":TBVAL(12)=[M:POH1]CUR

    TBPAR(13)="avenantdeb":TBVAL(13)="0"
    TBPAR(14)="avenantfin":TBVAL(14)="0"

    TBPAR(15)="comsolddeb":TBVAL(15)="0"
    TBPAR(16)="comsoldfin":TBVAL(16)="0"

    TBPAR(17)="etatlivdeb":TBVAL(17)="0"
    TBPAR(18)="etatlivfin":TBVAL(18)="0"

    TBPAR(19)="etatfacdeb":TBVAL(19)="0"
    TBPAR(20)="etatfacfin":TBVAL(20)="0"

    TBPAR(21)="codimp":TBVAL(21)="0"

    TBPAR(22)="filnam":TBVAL(22)="C:\Sage\X3V11\folders\PILOT\tmp\"+[M:POH0]POHNUM+".pdf"


    Call ETAT("BONCDE2_EMAIL","FILEPDF","",0,"",TBPAR,TBVAL)From AIMP3

    End

    After that i created a copy of default PO report and created -  BONCDE2_EMAIL

    I created a specific script ZBONCDE and call this in the specific script of the BONCDE2_EMAIL report.  below is my code.

    Subprog IMPRIME(NBPAR,PARAMETRE)

    Local Integer YTEMP

    For YTEMP = 0 To 30

    If [M:AIP]TBPAR(YTEMP) ="filnam"

    FICHIER = [M:AIP]TBVAL(YTEMP)
    FMTFIC = 29 
    infbox FICHIER

    Break

    Endif

    Next

    End


    $ACTION

    Case ACTION

    When "FICHIER" : Gosub FICHIER From ZBONCDE
    #When "IMPRIME" : Gosub IMPRIME From ZBONCDE


    When Default

    Endcase
    Return

    $FICHIER

    #If GSERVEUR = 0

    If dim(FICHIER)

    Local Integer YTEMP

    # Find the parameter named filnam, and override the report file name with this value


    For YTEMP = 0 To 30


    If [M:AIP]TBPAR(YTEMP) ="filnam"

    FICHIER = [M:AIP]TBVAL(YTEMP)


    Break


    Endif


    Next


    #Endif

    Endif


    Return

    But after creating the purchase order the pdf file is not getting created.

    Even though if i call the same code from SPEPOH  using the following method the file is creating

    $APRES_CRE

    Kindly advise how to resolve this.

    Thanks

  • 0 in reply to Shereef

    I am not an expert about workflow but are you sure this can't be done by standard configuration (w/o code). again refer to the example about customer invoice:

    https://www.sagecity.com/support_communities/sage_erp_x3/b/sageerp_x3_product_support_blog/posts/how-to-setup-a-workflow-to-email-invoice-to-customer-contact

  • 0 in reply to Julien Patureau

    Thank you Julien for the reply..

    This will not serve the purpose. My requirement is to attach the PDF in the same workflow mail for approval. 

    The above configuration will sent a separate mail.

    Thanks,

    Shereef N 

  • 0 in reply to Shereef

    Is your infbox being executed when the workflow is triggered?

  • 0 in reply to Israel Braunfeld

    Yes Israel.

    Both  infbox in Subprog PRINTPO() and Subprog IMPRIME(NBPAR,PARAMETRE) are executing but one thing i noticed is after executing the code in the IMPRIME and $FICHIER the code is not return back to this

    Call ETAT("BONCDE2_EMAIL","FILEPDF","",0,"",TBPAR,TBVAL)From AIMP3

    I put a infbox after this ETAT method it is not executing.

    But same time if i call my code through $APRES_CRE code is return back to ETAT method and executing the infbox after that. In this way pdf is creating also. But when call through workflow start action it is not working.

    Thanks,

    Shereef N

  • 0 in reply to Shereef

    Did you ever find a resolution to this issue?