Dear Members, This code to "Create Auto Receipt for a Sales Invoice after Sales Voucher Entry Completion". Please find the below, "Which works As per Requirement by using a Button (SetVchID)". Problem with using code : "On : Form Accept : @@IsSales : CALL : SetInvVchID". Noticed : the value of System Variable will be 0 by using "On:FormAccept" and gets correct value by using above referred "Button (SetVchID)" ;============= Code ===================== [System : Variables] Variable : TrInvUniqueVchID : String : "" Variable : TrRptVchNo : String : "" Variable : TrRptDate : Date : "" Variable : TrRptAmount : Amount : "" Variable : TrRptPartyName : String : "" [#Form: Export Invoice] Button : SetVchID On : FormAccept : Yes : Form Accept On : Form Accept : @@IsSales : CALL : SetInvVchID ; : $$Sprintf@VchMasterID:$MasterID [Button: SetVchID] Key : Alt + X Action : Call : SetInvVchID ;: $$Sprintf@VchMasterID:$MasterID [Function: SetInvVchID] ;Parameter : TrInvID : String 10 : Set : TrInvUniqueVchID : $$Sprintf@VchMasterID:$MasterID 11 : Set : TrRptVchNo : "R/" + $(Voucher, ##TrInvUniqueVchID).VoucherNumber 12 : Set : TrRptDate : $(Voucher, ##TrInvUniqueVchID).Date 13 : Set : TrRptAmount : $(Voucher, ##TrInvUniqueVchID).Amount 14 : Set : TrRptPartyName : $(Voucher, ##TrInvUniqueVchID).PartyLedgerName 30 : MSGBOX : "Message" : ##TrInvUniqueVchID ;TrRptVchNo 31 : Msg Box : "Message" : $(Voucher, ##TrInvUniqueVchID).VoucherNumber 32 : Msg Box : "Message" : $(Voucher, ##TrInvUniqueVchID).PartyLedgerName 33 : Msg Box : "Message" : $(Voucher, ##TrInvUniqueVchID).InventoryEntries.StockItemName 40 : Call : CreateReceipt ;50 : Action : Print Report : InvPlusRpt 50 : Return [Function: CreateReceipt] ;;================ Function to Create Receipt Voucher 03 : MSGBOX : "Message" : "Do U Want to Create Receipt for this Sales Voucher" 04 : Query Box : "Confirm Y/N" : Yes : No 05 : MSGBOX : "Message" : ##TrRptVchNo 06 : Msg Box : "Message" : ##TrRptPartyName 25 : IF : $$LastResult 30 : SET : SVViewName : $$SysName:AcctgVchView 35 : SET : SV VoucherType : $$VchTypeReceipt 40 : NEW OBJECT : Voucher 60 : SET : SVVoucherType : "Receipt" 70 : SET VALUE : Date : ##TrRptDate 80 : SET VALUE : VoucherTypeName : $$VchTypeReceipt 85 : SET VALUE : VoucherNumber : ##TrRptVchNo 90 : INSERT COLLECTION OBJECT : LEDGERENTRIES 100 : SET VALUE : LedgerName : ##TrRptPartyName 105 : SET VALUE : IsDeemedPositive : No 110 : SET VALUE : Amount : ##TrRptAmount 115 : SET TARGET : .. 130 : INSERT COLLECTION OBJECT : LEDGERENTRIES 140 : SET VALUE : LedgerName : "BOB" 150 : SET VALUE : IsDeemedPositive : Yes 160 : SET VALUE : Amount : ##TrRptAmount 170 : SET TARGET : .. 180 : SET VALUE : PersistedView : ##SVViewName 190 : CREATE TARGET 200 : MSGBOX : "Status" : "Created Receipt \n Voucher(s) !!" 204 : ELSE 205 : MSGBOX : "Message" : â€Dont Create Receipt†206 : ENDIF 300 : RETURN