Categories
Dynamics NAV HOW TO Microsoft

HOW TO change data for all Companies in NAV

HOW TO change data for all Companies?

You have different ways to complete this task, the choice depends from how many lines or Companies you have. In the following steps I will explain you how to change data for all Companies in C/SIDE using the CHANGECOMPANY Function (Record):

  1. Create a new ProcessingOnly Report using with the System Table 2000000006 – Company as Data Source of a DataItem.
  2. Declare a C/AL Globals Variable of DataType Record with the table that you need.
  3. Insert the following code in the OnAfterGetRecord trigger

    TO MODIFY

    [sourcecode lang=”Cside”]
    GLSetup.CHANGECOMPANY(Name);

    GLSetup.MODIFYALL("Allow Posting From", 010114D);
    GLSetup.MODIFYALL("Allow Posting To", 310114D);
    [/sourcecode]
    or

    TO DELETE

    [sourcecode lang=”Cside”]
    ChangeLogSetup.CHANGECOMPANY(Name);

    ChangeLogSetup.DELETEALL;
    [/sourcecode]

Here find another reading suggestion, this time in T-SQL: HOW TO run SQL query for multiple companies in NAV database

Did my HOW TO help you? Leave a reply.

Categories
Dynamics NAV HOW TO Microsoft

HOW TO calculate the Day of the Year number in C/SIDE

You can calculate the Day of the Year number in C/SIDE by the difference between the date (in my example I use the current date defined by the operating system using the function TODAY) and the first day of year of the date using the CALCDATE function. You need to add 1 to the result to include the day of the date that you are using.

HOW TO calculate the Day of the Year number in C/SIDE

[sourcecode lang=”Cside”]
Number := TODAY-CALCDATE(‘<-CY>’,TODAY)+1;
[/sourcecode]

If you need it as Text you need to convert it using the FORMAT function
[sourcecode lang=”Cside”]
String := FORMAT(TODAY-CALCDATE(‘<-CY>’,TODAY)+1);
[/sourcecode]

Did my HOW TO help you? Leave a reply.