web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

select and compare packing slip id from tables custPackingSlipTrans and salesParmSubLine is not working.

(0) ShareShare
ReportReport
Posted on by 1,443

Hi,

select firstonly _sl where _sl.SalesId == custInvoiceTrans.OrigSalesId && _sl.ItemId == custInvoiceTrans.ItemId &&       

     _sl.InventTransId == custInvoiceTrans.InventTransId && _sl.LineNum == custInvoiceTrans.LineNum && _sl.PackingSlipId == salesParmSubLine.DocumentId;

    return _sl.CIT_Smg_BlockPcs;

 

Note: 1.  _sl = custPackingslipTrans

         2.  DocumentId referes to packing slip Id in table 'SalesParmSubLine'

 

When i debug above code it takes values for all fields except for salesParmSubLine.DocumentId and not returns any value. If I remove _sl.PackingSlipId == salesParmSubLine.DocumentId then it returns first record of the _sl (custPackingslipTrans) table.

 

Need help,

 

Thanks,

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vlad Brisan Profile Picture
    75 on at

    Hi,

    Did you preselected salesParmSubLine.DocumentId? Also, it is normal just to bring you the first record considering you used firstonly. Can you tell me what do you want to do in your code? you could try to use it like:  

    while select _sl where _sl.SalesId == custInvoiceTrans.OrigSalesId && _sl.ItemId == custInvoiceTrans.ItemId &&      

        _sl.InventTransId == custInvoiceTrans.InventTransId && _sl.LineNum == custInvoiceTrans.LineNum {

    if( _sl.PackingSlipId == salesParmSubLine.DocumentId)

    {

    return _sl.CIT_Smg_BlockPcs

    }

    else

    {

    //your code

    }

    }

  • Mirza Mujib Ur Rahman Baig Profile Picture
    1,443 on at

    Hi Brisan,

    What I want is

    if _sl.PackingSlipId == salesParmSubLine.DocumentId then I'll retreive the value _sl.CIT_Smg_BlockPcs and print it on report (sales invoice report).

    Note: 1. _sl = custPackingSlipTrans

    If I write the above code without if condition i.e. _sl.PackingSlipId == salesParmSubLine.DocumentId

    then I'm getting the value of first record from table _sl.

    So i tried to put the if condition i.e. _sl.PackingSlipId == salesParmSubLine.DocumentId

    I hope it is clear,

    Thanks again

  • Suggested answer
    Vlad Brisan Profile Picture
    75 on at

    Ok. then you should have something like this:

    select  firstonly _sl where _sl.SalesId == custInvoiceTrans.OrigSalesId && _sl.ItemId == custInvoiceTrans.ItemId &&      

       _sl.InventTransId == custInvoiceTrans.InventTransId && _sl.LineNum == custInvoiceTrans.LineNum ;

    //here you get the value of the packing slip coresponding with the custInvoiceTrans in the report

    select firstonly salesParmSubLine where salesParmSubLine.DocumentId == _sl.PackingSlipId ;

    //here you check if a salesParmSubLine  exists for that packing slip

    if( salesParmSubLine)

    {

    return _sl.CIT_Smg_BlockPcs ;

    }

    else

    {

    //do nothing

    }

    Do you try to modify a custom or a standard report?

  • Suggested answer
    kehlet Profile Picture
    462 on at

    The LineNum could be inconsistent, also the InventTransId is unique, and for _sl you used SaiesId, not OrigSalesId (although it may be irrelevant, it could still be different from CustInvoiceTrans.OrigSalesId) so try rewriting it as:

    select firstonly _sl where _sl.OrigSalesId == custInvoiceTrans.OrigSalesId && _sl.InventTransId == custInvoiceTrans.InventTransId && _sl.PackingSlipId == salesParmSubLine.DocumentId;

       return _sl.CIT_Smg_BlockPcs;

  • Mirza Mujib Ur Rahman Baig Profile Picture
    1,443 on at

    Thanks Brison,

    Above code just brings the first record. It is not validating/checking particular packing slip number.

  • Mirza Mujib Ur Rahman Baig Profile Picture
    1,443 on at

    Hi Kehlet,

    I tried the above code, it didn't work.

    Thanks

  • kehlet Profile Picture
    462 on at

    Can you post some values from the tables?  Turn on the debugger and let us know these values:

    _sl.OrigSalesId

    _sl.InventTransId

    _sl.PackingSlipId

    custInvoiceTrans.OrigSalesId

    ustInvoiceTrans.InventTransId

    salesParmSubLine.DocumentId;

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dekion Profile Picture

dekion 4

#2
Virginia99 Profile Picture

Virginia99 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans