Running PowerShell from VS Code

Did you know you can run PowerShell from Visual Studio Code?

One of the biggest strength of VS Code is its diversity and the fact it is very light weight. I have already been using VS Code to do a lot of things with Git for a while because it natively integrates nicely with Git which is a huge plus.

Now a while back I tried to use PowerShell with VS Code but it was just not working well at the time, but recently I tried again and things have changed a lot. If you install the PowerShell extension from Microsoft you can now edit and run PowerShell scripts natively inside VS Code just like you can from PowerShell or PowerShell ISE.

You can find the extension here:

https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell

VS Code – One tool to rule them all.

Is My Record Temporary (Part 2)?

Back in July I wrote a blog on how to test if Records are temporary or not.

You can read it here.

Microsoft has now added it so you can directly test if a record is temporary or not with out any extra coding.

You define a record and like “Cust” as a variable of Record based on the Customer table. Now you can write things like.

2017-06-25_14-58-20

Thanks Microsoft. Great to see you implement my suggestions.

 

Transform or …

Looking at the vast majority of partners today they still sell one off project in east, west, north and south. Partners have gotten so comfortable doing what they have always done that they continue to do it because it seems like the sure thing to do.

However the world is rapidly changing and customer increasingly see through the cost of maintaining custom software. Customers typically sign off on traditional project, so they now own the bugs that are left in the custom software including the burden of fixing them. The software is also not improving with an ever changing industry requiring better and smarter ways of getting things done including new regulations and opportunities.

Customer get stuck back on older versions with costly upgrades or reimplementation’s as a consequence. This means the customer typically every 7 years or so will consider an upgrade, reimplementation or a new product. Any one of them require training, lots of time to consider the options, dedicated staff to manage or be part of managing the project, new hardware, roll out, many rounds of testing, headaches and money.

So why do customers and partners allow it?

Increasingly customers say no. That is not where we need to be. Customers wants to focus on their business just like partners should focus on delivering value to customers. In other words partners need to transform their business model and delivery or …

Today we are heading to the cloud. We are heading agile.

Partners should focus on their industry knowledge and create small or big apps to resolve customer issues so customers than can pick and select to add together one way or another. We are heading to a world that works like the great Danish and world famous toy called LEGO which is a acronym for the Danish words “Leg Godt” which means “Play Well”.

So what does this mean for the channel.

Partners that don’t have industry knowledge have an issue. My advise is get it or partner with someone who has it but no product knowledge.

Secondly change the way you deliver software. Look in to SCRUM or some Agile form of delivery. It is proven to work, but there is no half way of doing it. You either transform your entire organization to work with SCRUM or you don’t. Doing it half and than saying it doesn’t work is not an option. SCRUM only works if you practice it through out your company.

Things are changing. Are you?

PLAY WELL my friends.

 

 

Is My Record Temporary?

Very often when developing we have logic we would like to execute on records, but only when the table is actually a real table and not when used as a temporary record. This could be things like inserting, modifying or deleting attached records in another table which would make no sense in most cases if the table you are currently in is temporary.

Now when we use a RecordRef we have a command that will return true or false based on the RecordRef in question is temporary or not. The command is called

RecordRef.ISTEMPORARY

However this command sadly doesn’t exist for Records.

So how can we get around that issue?

I have created a RecordRefLibrary codeunit that contains the following 2 functions among others

IsVariantTemporary(PassedVariant : Variant) : Boolean

Variant2RecRef(PassedVariant,RecRef);

EXIT(RecRef.ISTEMPORARY);

Variant2RecRef(PassedVariant : Variant;VAR RecRef : RecordRef)

CASE TRUE OF

PassedVariant.ISRECORD :

RecRef.GETTABLE(PassedVariant);

PassedVariant.ISRECORDREF :

RecRef := PassedVariant;

ELSE

ERROR(UnsupportedTypeErr);

END;

Now in each table where I need it I add the following function

IsTemporary() : Boolean

EXIT(RecordRefLibrary.IsVariantTemporary(Rec));

Now I can write

Record.IsTemporary

anywhere I use the Record and it will return if the record I am currently in is temporary or not.

I could of course also just call directly to the codeunit if I would like not to make changes to the Table, however it would be good practice in my view to expose the functionality on each table where needed, so everybody knows where to find it.

Hopefully this was helpful to some of you if you don’t have a solution for this already.

A couple of “secret” switches in Dynamics NAV

Unless you are very new to Microsoft Dynamics NAV I am sure you know of the General Ledger Setup.

This is where we setup most General Ledger related settings such as Check G/L Account usage, the local Currency Unit (LCY) ,if VAT is in use or if we are using Unrealized Tax.

Many might not be aware that this also has a few hidden settings.

If you run table 98 General Ledger Setup from the Object designer you will see a few more fields then what the users sees in the standard page in your client.

A few that I have found very use full from time to time are:

Field What the helps say
Mark Cr. Memos as Corrections Specifies whether to automatically mark a new credit memo as a corrective entry.

 

You can use the field if you need to post a corrective entry to a customer account.

 

If you place a check mark in this field when posting a corrective entry, the program will post a negative debit instead of a credit or a negative credit instead of a debit. The Debit Amount field (or Credit Amount field) on the relevant account will then include both the original entry and the corrective entry, which will have no effect on the debit (or credit) balance.

Amount Decima Places Determines the number of decimal places the program will display (for example, on invoices and in reports) for amounts in $. The default setting, 2:2, specifies that amounts in $ will be shown with two decimal places.
Unit-Amount Decimal Places Determines the number of decimal places the program will display (for example, on invoices and in reports) for sales and purchase prices for items, and for sales prices for resources in $. The default setting, 2:5, specifies that sales and purchase prices in $ will be shown with a minimum of two decimal places and a maximum of five decimal places.
Amount Rounding Precision Specifies the size of the interval to be used when rounding amounts in $.

Amounts will be rounded to the nearest digit.

Unit-Amount Rounding Precision Specifies the size of the interval to be used when rounding unit amounts (that is, item or resource prices per unit) in $.

 

Use this field to have the program round item prices on invoice lines when you sell to a customer or buy from a vendor in $. The program rounds the amount in the Unit Price field for customers and the Direct Unit Cost field for vendors, on the invoice line. Amounts will be rounded to the nearest digit.

Especially the “Unit-Amount Rounding Precision” have come in great use many times where customers have special rounding requirements on their unit amounts (things like Item Costs, Prices with more).

One setting to rule them all.

 

Let’s Clean up NAV #13 – Chain Name

Adding to Luc van Vugt little miniseries on his blog about things we can do to clean up NAV here is another one.

Table 18 Customer has a little known field called “Chain Name”. It is field No. 18 and has been in the system “forever”. Well almost…

If I remember right this field has roots as far back as I can remember and I actually use it quite often as customers often request some kind of Chain association to be indicated on the customer card. However the field as it is today has a few issues. First it is not located on any page so kind of hard to use for the end user and secondly it doesn’t have a table, but is free text (or I should say Code as it is a code 10 field).

Now we normally don’t call code fields something ending on “Name”, but that is maybe beside the point in this case.

My suggestion would be one of two:

Either we need to get rid of the field and remove it from the table. Hey that is the easy thing to do.

Alternative we should rename the field to “Chain Code”. Create a Chain Table with associated List Page and setup a table relation. We of course should also add the field to the customer card.

My 10 cent on this one.