Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

Customization in Accounts Payable

(0) ShareShare
ReportReport
Posted on by 1,348

Hi All

I have a customization issue and I do hope that someone could point me in the right direction.

I recently started doing customizations in SL but it is certainly not my strong point.  There was an existing customizations on the voucher and adjustment screen, specifically on the subaccount field that the description in the last segment will go over as the transaction description.

Now this was working fine, until I did a customization on the invoice field to stop the user from entering the same invoice number for the same vendor.  Right now the system by default, alerts the user but does not stop them.  The client wants to stop the user.

The code is working but for some reason that totally escapes me, when it works, it is preventing the other customization from firing.   Is there something that I am missing, could some one point me in the right direction on what could be the problem?

If you need further clarification let me know.  Thanks so much in advance.

Lisa 

*This post is locked for comments

  • Suggested answer
    Apps Mexico Profile Picture
    1,090 on at
    RE: Customization in Accounts Payable

    Hi,

    My recomendation is that you use the SDK native functions, maybe this can help you.

    If serr1 = 0 Then

           Call MessBox("Invoice number has already been entered for this vendor.  Please enter a new number.",  MB_ICONEXCLAMATION, "ERROR")

           retval = ErrNoMess

    Exit Sub


    End if

    The code for the subaccount is as follows:

    SqlStr = "Select Description from SegDef where FieldClassName = 'SUBACCOUNT' and SegNumber = '6' and ID " = " + SParm(Mid(ChkStrg, 9, 2))"

    serrl = SqlFetch1(c1, SqlStr, StrDesc, LenB(StrDesc))

    If serr1 <> NOTFOUND Then

    Call setobjectvalue("cTranDesc", StrDesc.Descr)

  • Sunita Profile Picture
    10 on at
    RE: Customization in Accounts Payable

    Lisa, it may be a good idea to use Option Explicit as first line in your Form/Module code. It will enforce variable declarations and checks.

  • Cynthia Audain Profile Picture
    1,348 on at
    RE: Customization in Accounts Payable

    Hi Sunita, after confirming that the SQL script was pulling data from the database, I had to dissect each line of the code to see what I may have missed and I figured out what was the problem.

    On looking closely at the second code, I realized that on the serr1 line, I put a "l" instead of a "1" and that was throwing off everything.   Now it is working perfectly.  

    Although I am not a programmer, I think simply things like this could be a programmer's nightmare if it is not picked up.

    Thanks a lot for your input though, it was greatly appreciated.

  • Sunita Profile Picture
    10 on at
    RE: Customization in Accounts Payable

    Hi Lisa, have you tried running a SQL Profiler trace. The templates provided by MS are well laid out with columns that will make the profiler data very consumable. They have a template for each version of SQL server. Yes, I have tried both sections of the code provided in your post, and they both work without any error. What version of SL are you working with? If you like, please post the complete code for Invoice Nbr and Sub Acct check event, and I will help review.

  • Cynthia Audain Profile Picture
    1,348 on at
    RE: Customization in Accounts Payable

    Hi Sunita,

    You mentioned in your previous post that retval = errnomess will prevent previous code from firing.  Could this be the issue here?  

    If not, is there someway I could specify the level that both code relate to, or this is not needed?

    I turn on the database calls and I am seeing a couple of errors but I am not sure I could make any sense out of it.  Below are two, I saw

    schk(pmsg=dbsqlexec,SqlCompile - Execute,poption=acctxref_acct  'HIPAC',  '90000' ,cursor=83,err=501)

    sqlcursor(cursor=83,name=83)

    Sql(cursor=83,"select acctxref.acct,acctxref.descr from acctxref WITH (NOLOCK)  where cpnyid = @parm1 and active = 1 and acct like @parm2 and (acctxref.acct between '90000' and 'zzzzzzzzzz') order by acct OPTION(FAST 500)")

    schk(pmsg=SqlCompile - dbcursoropen,poption=select acctxref.acct,acctxref.descr fro,cursor=83,err=10215)

    I am not sure if that means anything....  Any further suggestions?

    Thanks

    Lisa

  • Cynthia Audain Profile Picture
    1,348 on at
    RE: Customization in Accounts Payable

    Hi Sunita, from what you discovered are you saying that both codes together are working properly on your end?

    I have tested both codes separately and they work fine so I know nothing is wrong with the code itself.  The problem is when I put them together, only the invoice customization works and not the subaccount.  I am still a bit confused on what is causing this and how to go about to fix it.

    I will turn on the database calls and see if that shows something that will help...

  • Sunita Profile Picture
    10 on at
    RE: Customization in Accounts Payable

    Lisa, please do note that the query I have tested with is on a system with different subaccount segments, which explains the SegNumber = 3 and the Mid function using starting position of 4. But the general statement construct is conveyed.

  • Sunita Profile Picture
    10 on at
    RE: Customization in Accounts Payable

    I have tested the code and it works fine. Invoice Nbr is in the header whereas the Subaccount and TranDesc are in the grid, hence handled at completely different levels and check events. Did you turn on the Database Calls in Tools/Options in SL and look at the log file. You may want to verify the SQL statement to see if there are records with description is available for the corresponding rows in SegDef. On a side note, there seems to be a typo in the code excerpt pasted in your post for the SQL query. Below is what I have used. Alternatively, you can use MessBox calls for debugging purposes to see your SQL string or the result from it to see if there was data retrieved.

    sqlstr = "Select Description from SegDef where FieldClassName = 'SUBACCOUNT' and SegNumber = '3' and ID = " & SParm(Mid(ChkStrg, 4, 2))

  • Cynthia Audain Profile Picture
    1,348 on at
    RE: Customization in Accounts Payable

    Thanks Rick & Sunita, for both your responses.

    To elaborate a bit on the code.  Both codes are on the check event and for the invoice code, I am using retval = ErrNoMess.     The tail end of the code is as follows:

    If serr1 <> NOTFOUND Then

           Call MsgBox ("Invoice number has already been entered for this vendor.  Please enter a new number.",  vbOKOnly, "ERROR")

           retval = ErrNoMess

    The code for the subaccount is as follows:

    SqlStr = "Select Description from SegDef where FieldClassName = 'SUBACCOUNT' and SegNumber = '6' and ID " = " + SParm(Mid(ChkStrg, 9, 2))"

    serrl = SqlFetch1(c1, SqlStr, StrDesc, LenB(StrDesc))

    If serr1 <> NOTFOUND Then

       sivMyApp.Controls("cTranDesc").value = StrDesc.Descr

    Let me know where I when wrong. Thanks again

  • Sunita Profile Picture
    10 on at
    RE: Customization in Accounts Payable

    Hello Lisa, can you please provide further details. If you have the code within check event of the field then using retval = errnomess will prevent the subsequent code to fire.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

#1
Community Member Profile Picture

Community Member 136

#2
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 102 Super User 2025 Season 1

#3
REUser Profile Picture

REUser 8

Featured topics

Product updates

Dynamics 365 release plans