Moved my "update" command to a different block and everything works great... d'oh!
--- In vantage@yahoogroups.com, "Nathan" <bonner.nathan@...> wrote:
>
> I am getting the subject error related to the following segment of my code:
>
> "Assign iAbsToday = ((Year(today) * 365.242199 + Month(today) * (365.242199 / 12) + Day(today) + 1)).
> If iWeekday = 6 then do:
> Assign iAbsToday = ((Year(today) * 365.242199 + Month(today) * (365.242199 / 12) + Day(today) + 3)).
> End."
>
> Code passes validation.
>
> Full error text is as follows:
>
> Error Detail
> ============
> Index and length must refer to a location within the string.
> Parameter name: length
>
>
> Stack Trace
> ===========
> at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
> at Bpm.CodeGen.Progress.FourGlActionGen.generateProcSerializer(ProcedureGen target, Hashtable htTP)
> at Bpm.CodeGen.Progress.FourGlActionGen.generateProcedureBody(Hashtable htTP)
> at Bpm.CodeGen.Progress.FourGlCodeGen.GenerateProcedure(String sSuffix)
> at Epicor.Mfg.UI.Bpm.Actions.ActionBase.CreateSourceCode(SourceCodeBlocks block, String sSuffix)
> at Epicor.Mfg.UI.App.BpMethodEntry.Transactions.ActionTransaction.SaveActionState()
> at Epicor.Mfg.UI.App.BpMethodEntry.Transactions.ActionTransaction.adapterUpdate()
> at Epicor.Mfg.UI.FrameWork.EpiMultiViewTransaction.Update()
>
> Full Code Text:
>
> def var iWeekday as dec no-undo initial 0.
> def var iAbsToday as dec no-undo initial 0.
>
> Assign iWeekday = weekday(today).
> Assign iAbsToday = ((Year(today) * 365.242199 + Month(today) * (365.242199 / 12) + Day(today) + 1)).
> If iWeekday = 6 then do:
> Assign iAbsToday = ((Year(today) * 365.242199 + Month(today) * (365.242199 / 12) + Day(today) + 3)).
> End.
>
>
> for each ttCRMCall no-lock where(ttCRMCall.Company = CUR-COMP and (ttCRMCall.RowMod = 'A' or ttCRMCall.RowMod = 'U')).
> for each CRMCall no-lock where(CRMCall.Company = ttCRMCall.Company and CRMCall.Date01 <= Today and CRMCall.CheckBox01 = FALSE ).
> If available CRMCall then do:
> def var xCustVendName as char no-undo initial ''.
> def var xContact as char no-undo initial ''.
> def var xConPh as char no-undo initial ''.
> def var xConEmail as char no-undo initial ''.
> def var xUser as char no-undo initial ''.
> Assign xUser = CRMCall.OrigDcdUserID.
> If CRMCall.OrigDcdUserID <> '' then do:
> For each UserFile no-lock where(UserFile.DcdUserID = CRMCall.OrigDcdUserID).
> If available UserFile then do:
> If UserFile.OSUserID <> '' then do:
> Assign xUser = UserFile.OSUserID.
> End.
> End.
> End.
> End.
> If CRMCall.CallCustNum <> 0 then do:
> For each Customer no-lock where(Customer.Company = CRMCall.Company and Customer.CustNum = CRMCall.CallCustNum).
> If available Customer then do:
> Assign xCustVendName = Customer.Name.
> Assign xConPh = Customer.PhoneNum.
> Assign xConEmail = Customer.EMailAddress.
> End.
> End.
> End.
> If CRMCall.CallVendorNum <> 0 then do:
> For each Vendor no-lock where (Vendor.Company = CRMCall.Company and Vendor.VendorNum = CRMCall.CallVendorNum).
> If available Vendor then do:
> Assign xCustVendName = Vendor.Name.
> Assign xConPh = Vendor.PhoneNum.
> Assign xConEmail = Vendor.EMailAddress.
> End.
> End.
> End.
> If CRMCall.CallConNum <> 0 then do:
> For each CustCnt no-lock where(CustCnt.Company = CRMCall.Company and CustCnt.CustNum = CRMCall.CallCustNum and CustCnt.ShipToNum = CRMCall.CallShipToNum).
> If available CustCnt then do:
> Assign xContact = CustCnt.Name.
> If CustCnt.PhoneNum <> '' then do:
> Assign xConPh = CustCnt.PhoneNum.
> End.
> If CustCnt.EMailAddress <> '' then do:
> Assign xConEmail = CustCnt.EMailAddress.
> End.
> End.
> End.
> End.
> If CRMCall.CallVConNum <> 0 then do:
> For each VendCnt no-lock where(VendCnt.Company = CRMCall.Company and VendCnt.VendorNum = CRMCall.CallVendorNum and VendCnt.PurPoint = CRMCall.CallPurPoint).
> Assign xContact = VendCnt.Name.
> If VendCnt.PhoneNum <> '' then do:
> Assign xConPh = VendCnt.PhoneNum.
> End.
> If VendCnt.EmailAddress <> '' then do:
> Assign xConEmail = VendCnt.EmailAddress.
> End.
> End.
> End.
>
> define variable vFrom as character no-undo initial ''.
> define variable vTo as character no-undo initial ''.
> define variable vCC as character no-undo initial ''.
> define variable vSubject as character no-undo initial ''.
> define variable vBody as character no-undo initial ''.
> define variable hEmailEx as handle no-undo.
>
> run Bpm/BpmEmail.p persistent set hEmailEx.
>
> assign vFrom = 'bonner.n@...'.
> assign vTo = string( xUser + '@...' ).
> assign vCC = vCC + string( CRMCall.ChangedBy + '@...' + '; ' + 'bonner.n' + '@...').
> assign vSubject = vSubject + 'CRM Call Followup Reminder'.
> assign vBody = vBody + string ('Company: ' + xCustVendName + Chr(10) + 'Contact:' + xContact + Chr(10) + 'Phone: '+ xConPh + Chr(10) + 'Email: ' + xConEmail + Chr(10) + 'Call Description: ' + CRMCall.CallDesc + Chr(10) + Chr(10) + 'Call Text: ' + Chr(10) + CRMCall.CallText ).
>
> run SendEmail in hEmailEx (
> false,
> CUR-COMP,
> vFrom,
> vTo,
> vCC,
> vSubject,
> vBody,
> string ( 'Company: ' + xCustVendName + Chr(10) + 'Contact:' + xContact + Chr(10) + 'Phone: '+ xConPh + Chr(10) + 'Email: ' + xConEmail + Chr(10) + 'Call Description: ' + CRMCall.CallDesc + Chr(10) + Chr(10) + 'Call Text: ' + Chr(10) + CRMCall.CallText )
> ).
> if valid-handle(hEmailEx) then delete procedure hEmailEx.
> leave.
> Run lib\UpdateTableBuffer.p(input BUFFER CRMCall:HANDLE, 'Checkbox01', TRUE).
> End.
> End.
> End.
>
>
> Help - I'm stumped but need this to work.
>
> Thanks,
>
> NB
>