SBX - Search With Button

SBX - Forum Post Title

Sales Line = Sales Header + Sales & Receivable setup

Microsoft Dynamics NAV Forum

manideep22 asked a question on 13 Jun 2019 4:48 PM

Question Status

Suggested Answer

Hi,

I have created a date field in sales line table and no.of days field in Sales & receivable setup table.

This date field should be combination of no.of days in sales & receivable setup and document date of sales header table.

How can I achieve this?

How these three tables are related ?

Reply
Teddy Herryanto responded on 16 Jun 2019 5:39 AM
My Badges

Try using calcdate.

Datefield := calcdate(dateformula,documentdate);

Reply
manideep22 responded on 17 Jun 2019 9:07 AM

Hi Teddy,

Where exactly to include the code? I already know how to code this, but not sure about where to place this.

Reply
Teddy Herryanto responded on 17 Jun 2019 2:43 PM
My Badges

On Sales Header table, on Document Date field OnValidate.

Reply
manideep22 responded on 17 Jun 2019 3:22 PM

I have written below code on Sales Header table, inside OnValidate of document date. But, the Job activity date inside sales line is not updating.

SalesLine."Job Activity Date" := CALCDATE('<+10D>',"Document Date");

Also, I'm still not sure on how to get the reference of no.of days field of sales & receivable setup into sales header table code.

Reply
manideep22 responded on 17 Jun 2019 4:19 PM

I have called this

UpdateSalesLines(FIELDCAPTION("Document Date"),FALSE);

And tried this inside UpdateSalesLines inside sales header table

CASE ChangedFieldName OF

 FIELDCAPTION("Document Date") :

   SalesLine."Job Activity Date" := CALCDATE('<+10D>',"Document Date");

END;

Reply
Teddy Herryanto responded on 18 Jun 2019 12:10 AM
My Badges

There are two places you need to put the code in.

First is the Sales Header in OnValidate Document Date. When you validate document date, it checks and update all the sales line - date field.

Second is in the OnInsert on Sales Line table.

Is there any reason why you put this new date field on Sales Line instead of Sales Header ?

Reply
manideep22 responded on 18 Jun 2019 12:16 AM

It’s part of requirement.

I’ll try putting it in both the places

Reply
manideep22 responded on 18 Jun 2019 9:53 AM

Hi Teddy,

I've tried placing the code in both OnValidate and on OnInsert but of no use. The Job Activity date is not getting updated.

Reply
Teddy Herryanto responded on 18 Jun 2019 2:26 PM
My Badges
Suggested Answer

is it not getting update or is it not reflected when you input the document date on the sales order ?

On the Sales Order page, under document date OnValidate, put below code as below to update the sales line.

CurrPage.SalesLines.PAGE.UpdateForm(TRUE);

if it's not working, show us the screenshot of your code.

Reply
manideep22 responded on 18 Jun 2019 2:43 PM

It’s not getting updated in the sales line table even though I have posted the document date in sales order.

Reply
Teddy Herryanto responded on 18 Jun 2019 2:26 PM
My Badges
Suggested Answer

is it not getting update or is it not reflected when you input the document date on the sales order ?

On the Sales Order page, under document date OnValidate, put below code as below to update the sales line.

CurrPage.SalesLines.PAGE.UpdateForm(TRUE);

if it's not working, show us the screenshot of your code.

Reply

SBX - Two Col Forum

SBX - Migrated JS