Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

To update CustPackingSlipJour table using SalesLine

Posted on by 1,457
hi , 
i was trying to update the custpackingslipjour table with sales line , but i am not able to pass the value from salesline ,can anyone one guide me on this .
below is my code .
 
thanks ,
Dinesh
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    To update CustPackingSlipJour table using SalesLine
    hi , 
    martin 
    i tried the same to do on cust invoice jour table when i invoice the return sales line , but i am getting this error 
    "
    Microsoft.Dynamics.Ax.Xpp.UpdateConflictNotRecoveredException: 'Cannot edit a record in Customer invoice journal (CustInvoiceJour).

    An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.'"
    i am getting the values in my code ,i was using insert method but , in debugger it the error is thrown on form source letter i am not getting which user process is not letting my reocrd update , my code is below and the insert method is not giving any error . but the vlaues are not reflecting on custinvoice jour .
    [ExtensionOf(tableStr(CustInvoicejour))]
    final class DTReturnOrderPackingSlipCustInvoiceTrans_Extension
    {
        public void insert()
        {
            CustInvoiceJour      custInvoiceJour;
            SalesLine            salesLine;
            SalesParmLine        salesParmLine;
            InventTransOrigin    inventTransOrigin;
    
            next  insert();
    
        select firstonly salesLine 
                join   salesParmLine
                 where salesParmLine.SalesLineRecId == salesLine.RecId
                join  inventTransOrigin
                 where  inventTransOrigin.InventTransId == salesParmLine.InventTransId
                  &&  salesParmLine.parmId  == this.ParmId
                
            if(salesLine.DTReturnOrderPackingSlip)
            {
                  
                if(custInvoiceJour)
                {
                    ttsbegin;
                    custInvoiceJour.selectforUpdate(true);
                    if(custInvoiceJour.DTReturnOrderPackingSlip)
                    custInvoiceJour.DTReturnOrderPackingSlip = salesLine.DTReturnOrderPackingSlip;
                    custInvoiceJour.Update();
                    ttscommit;
                }
    
            }
            info(strFmt('%1salesid ', this.SalesId));
         
        }
    
    }
    thanks ,
    Regards,
    'Dinesh 
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    To update custpaclingslipjour table using salesline
    yes 
    you r right  this. sales id is not getting any values and other fields too
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    To update custpaclingslipjour table using salesline
    Are you saying that the actual problem is that the following query doesn't return any record (and the rest of code isn't relevant at the moment)?
    select firstonly custPackingSlipJour
        where custPackingSlipJour.SalesId == this.SalesId
           && custPackingSlipJour.PackingSlipId == this.PackingSlipId
           && custPackingSlipJour.DeliveryDate == this.DeliveryDate;
    If so, I would start by checking whether this.SalesId, this.PackingSlipId and this.DeliveryDate contain expected values. If so, the explanation must be that the CustPackingSlipJour record doesn't exist. Then you should look again where you're using the code from.
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    To update custpaclingslipjour table using salesline
    hi ,
    i have simplyfy my code , hope you are getting my doubt .
    [ExtensionOf(tableStr(CustPackingSlipTrans))]
    final class DTReturnOrderPackingSlipCustPackingSlipTrans_Extension
    {
        public void initFromSalesLine(SalesLine _salesLine,
                                      boolean   _isExtensionIntrastatEnabled )
        {
            CustPackingSlipJour     custPackingSlipJour;
          
            next initFromSalesLine(_salesLine,
                                      _isExtensionIntrastatEnabled );
    
            if(_salesLine.DTReturnOrderPackingSlip)
            {   
                 // i need to pass the value from sales line to get the record in custPackingSlipJour
                select firstonly  custPackingSlipJour
                  where custPackingSlipJour.SalesId == this.SalesId
                   && custPackingSlipJour.PackingSlipId == this.PackingSlipId
                   && custPackingSlipJour.DeliveryDate == this.DeliveryDate;
    
               // here custPackingSlipJour is null  in debugger so i am not getting inside if 
                if(custPackingSlipJour)
                {
                    ttsbegin;
                    custPackingSlipJour.selectforUpdate(true);
                    custPackingSlipJour.DTReturnOrderPackingSlip = _salesLine.DTReturnOrderPackingSlip;
                    custPackingSlipJour.Update();
                    ttscommit;
                }
            }
        }
    }
     
     
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    To update custpaclingslipjour table using salesline
    i have tried new select statement , but not getting value in here also sale line cannot pass record into related table, i have tested the query in sql it is working 
      select salesLine.InventTransId,salesLine.DTRETURNORDERPACKINGSLIP,custPackingSlipJour.PackingSlipId,* from custPackingSlipJour
    	              join CustPackingSlipTrans
                       on  CustPackingSlipTrans.SalesId = custPackingSlipJour.SalesId  
                      and  CustPackingSlipTrans.PackingSlipId = custPackingSlipJour.PackingSlipId 
                      and  CustPackingSlipTrans.DeliveryDate = custPackingSlipJour.DeliveryDate
                   join SALESLINE
                    on  custPackingSlipTrans.SalesId  = salesLine.SalesId
                   and  custPackingSlipTrans.InventTransId = salesLine.InventTransId
    			     where salesLine.SalesId = '10188466'
    				 and   salesLine.InventTransId = '04080278'
    but this is not getting values from sales lines.
    select firstonly   custPackingSlipJour
                    where custPackingSlipJour.SalesId == this.SalesId
                      && custPackingSlipJour.PackingSlipId == this.PackingSlipId
                      && custPackingSlipJour.DeliveryDate == this.DeliveryDate
                    join custPackingSlipTrans
                    where custPackingSlipTrans.OrigSalesId == _salesLine.SalesId
                      &&  custPackingSlipTrans.InventTransId == _salesLine.InventTransId;
     
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    To update custpaclingslipjour table using salesline
    so i am not getting value in, i n need to pass the sales line in here to get if (custpackingslipjour)  
     
    select firstonly  custPackingSlipJour
                  where custPackingSlipJour.SalesId == this.SalesId
                   && custPackingSlipJour.PackingSlipId == this.PackingSlipId
                   && custPackingSlipJour.DeliveryDate == this.DeliveryDate;
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    To update custpaclingslipjour table using salesline
    hi 
    martin 
    thanks for reply ,
    when i use debugger the value in , is null ,
     
                if(custPackingSlipJour)
  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    To update custpaclingslipjour table using salesline
    I'm sorry, but "not able to update record" says merely that you have a problem, but it doesn't describe the problem.
     
    Please tell us what prevents you from updating the record. For example, are you getting an exception? If so, at which line of code it is and what does the error message says? Or do you mean that your code doesn't even call update? Then use the debugger to find which condition is to blame.
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    To update custpaclingslipjour table using salesline
    hi martin 
    thanks for reply 
    i am having field on salesline named original packing slip , which i want to flow to  Custpackingslip jour table when the post packing slip so i use initfromsalesline() of custpackingsliptrans  , how can i flow the field from salesline to custpackingslipjour , i have custom field on custpackingslipjour , i am getting value in if(_salesLine.DTReturnOrderPackingSlip) but not able to update record in  custpackingslipjour.can you please guide me on this . i will remove that comma seperator part .
     select firstonly  custPackingSlipJour
                  where custPackingSlipJour.SalesId == this.SalesId
                   && custPackingSlipJour.PackingSlipId == this.PackingSlipId
                   && custPackingSlipJour.DeliveryDate == this.DeliveryDate;
    i need to pass the value of sales line i am getting in to select query but not getting how to do it .
  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    To update custpaclingslipjour table using salesline
    Please explain your problem to us. It's not clear to me what you mean by "i am not able to pass the value from salesline".
     
    By the way, putting a list of comma-separate values to a field violates the very basics of a meaningful design of relational databases. The correct approach is creating a separate table (with 1:N relation) and putting values as records there.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans