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 VB.NET Visual Studio

HOW TO calculate the weekday name in RDLC

To calculate the weekday name in RDLC you can use a combination of two Visual Basic functions:

  1. DatePart
    Syntax

    DatePart(interval,date[,firstdayofweek[,firstweekofyear]])
    

    firstdayofweek is an Optional parameter and the Default value is 1 (Sunday).
    firstweekofyear is an Optional parameter and the Default value is 1 (January).

  2. WeekdayName
    Syntax

    WeekdayName(weekday[,abbreviate[,firstdayofweek]])
    

    abbreviate is an Optional parameter. A Boolean value that indicates if the weekday name is to be abbreviated.
    firstdayofweek is an Optional parameter and the Default value is 1 (Sunday).

  3. HOW TO calculate the weekday name in RDLC

    CORRECT RESULTS
    [sourcecode language=”VB”]
    =WeekDayName(DatePart("w", Fields!CurrentDate_System.value,0))
    =WeekDayName(DatePart("w", Fields!CurrentDate_System.value,0,0))
    [/sourcecode]

    WRONG RESULTS
    [sourcecode language=”VB”]
    =WeekdayName(DatePart("w", Fields!CurrentDate_System.Value))
    =WeekdayName(DatePart("w", Fields!CurrentDate_System.Value),false,0)
    [/sourcecode]

    Did my HOW TO help you? Leave a reply.