Jobs or Hello World in Dynamics 365 for Operations

There are no more jobs in D365 for Operations. Instead now you can use a runnable class.

Create project. Right click on the project/ add item/ dynamics 365 Items/code/ Runnable class (Job)

1

Enter the name,

Add some code to the method main.2

Right click on the new class select “Set as a startup object”

And press run

Advertisements

How to check weather all customers have nameAlias defined

I think one of the easier methods would be to run  this job, which will show number of all customers, and customer with Name Alias defined.

static void AmountOfCustomersWithNAmeAlias(Args _args)
{
    CustTable custtable;
    int counter1, counter2;

    while select CustTable
    {
        counter1++;
        if (CustTable.nameAlias())
        {
            counter2++;
        }
    }
   info (strFmt(“Counter1 %1, counter2 %2”,counter1, counter2));
}

generating CSV record with labels out of table fields

So pretty much this is the way to generate a line of csv file, getting value of the query table daa soucre field label values.

QueryRun qR;
Query _query;
Common record;

DictTable dictTable;
FieldId fieldId;
DictField dictField;

str output =””;
int x,y;

_query = new Query(“<nameOfTheQuery>”);
qR = new QueryRun(_query);
for(x = 1; x <= _query.dataSourceCount(); x++)
{

dictTable = new DictTable(_query.dataSourceNo(x).table());
for(y = 1; y <= _query.dataSourceNo(x).fields().fieldCount(); y++)
{
fieldId = _query.dataSourceNo(x).fields().field(y);
dictField = new DictField(dictTable.id(), fieldId);

if(dictField.arraySize() > 1)
{
continue;
}

output += strFmt(“%1%2”, dictField.label(), “|”);

}
}
info( output);
}