Coding, Day to Day

Business Central – Dude, Where’s the Warranty Date?

There is always something new to learn everyday in Business Central. I was doing some setup to test item tracking involving serial numbers and was fiddling with the warranty date required setting (See screenshot below). Somehow, the warranty column did not show up in the item tracking line page for both Purchase and Sales lines.

Item Tracking Card

After consulting one of the senior functional consultants, I learnt that the warranty column had to be manually added in via the personalization feature. The end result is as shown below.

Item Tracking Lines

Wonder why they couldn’t tie the visibility of the warranty date column to the setup. Am I missing anything?

Coding, Day to Day

Snakes and Camels?

I was intrigued by an email from a vendor that mentioned snakes and camel case for the field names from an API call. “What snakes and camels? Since when do animals come partying in our project?”, I wondered. These terms are quite rarely heard these days. Typically people deal with title case, uppercase, lowercase etc., so I decided to do some research to find out what is it about.

Camel case and snake case are different forms of variable naming convention style. These two are the more popular ones that programmers use. Camel case and snake case stand at opposite ends of the naming convention spectrum and we shall see how and what they are like in this article. You might even be using them without knowing what they are called, just like me.

Snake case uses underscore between words to create separation. As variable names cannot contain spaces, this reduces readability when multiple words are combined to describe its purpose. Snake case tries to minimize this shortcoming.

a_snake_case_name_looks_like_this

It is immediately apparent why it is called a snake case. It do looks like a snake wiggling amongst the codes. One study has found that readers can recognize snake case variable names more quickly than camel case.

Camel case uses capitalization of the first character of each word to denote the start of a new word. It is also known as Pascal case or upper camel case. When it is not, it is often referred to as lower camel case.

ACamelCaseNameLooksLikeThis

It is obvious why it is called a camel case. It does looks like it has a lot of humps doesn’t it. Do note that it is different from title case where it retains space as word separators. Camel case has been criticized as not been as readable compared to other methods due to the removal if spaces (and/or alternative replacements) and uppercasing of every word.

From the above examples, it seems pretty obvious that snake case provides better readability, but that is just my opinion. Some people find camel case easier to read. To me readability is especially important in coding. If your team member or others are unable to understand it, it is useless. The coding language and platform that you are using do affect your choice of naming convention. It is better to follow the standards (if there are any).

Day to Day, Thoughts

Terra Luna Fallout – Retrospect & Takeaway

The Terra Luna fallout needs no introduction, especially since it had became global news and the impact was so great that it was the talk of the town amongst common folks who were totally clueless on cryptocurrencies. That had also painted a big red bullseyes for the regulators.

It also took quite a while for me to get a grip on the situation and understand what happened. A lot of people had been burnt by this fallout and some time is needed to calm down and assess the damage.

Brief Background

Unless you have been living under rock, here is a brief summary of what happened.

TerraUSD (UST) is an algorithmic stablecoin that maintains its 1:1 peg with the US Dollar via software logic instead of being backed by physical assets (unlike USDC). LUNA is the native token of Terra, a blockchain developed by Terraform Labs and is primarily used to operate the collateralizing mechanisms that ensures UST’s peg. USTs are minted by burning LUNA and can be also swapped for LUNA. For example, if the UST values goes above USD$1, the equivalent value of LUNA would be burned, which mints more UST, making it less valuable. If the UST price drops below USD$1, they are swapped for LUNA, which in turn makes UST more valuable.

Early this month, a large amount of UST was dumped, and UST started to de-peg. As it dragged on, with the backdrop of lack of official information, more UST was sold in mass panic. Hence it was not just a case of UST being de-pegged but it also had an effect of crashing the price of LUNA. With both UST and LUNA prices in free-fall, the rest is history.

Biggest run in crypto history.

Aftermath

Needless to say, it triggered a fallout on the broader crypto market as well as getting international headlines. Even Tether (USDT), another stablecoin, but backed by physical assets de-pegged for a brief period of time. A lot of people’s hard earn money went down the sink and talks about suicides were everywhere. I think it was the largest wipe out in the crypto market.

Personal Experience

I had done my research and knew of the risks involving algorithmic stablecoins and how Terra Luna works. I knew that it is a matter of time before a serious de-peg occurs and that the potential of a bank run is always there. Even with their Bitcoin and other reserves, it is in my belief that they are unlikely to survive a full run onslaught.

At that time, before the great crash, 5-8% of my portfolio is in UST and LUNA. I was expecting that I would have enough warning and buffer time to exit if I had to. In the end, I lost almost everything despite knowing what I had gotten into and having an “exit plan”.

Then came the de-peg and crash.

I didn’t expect it to free fall so fast and both at the same rate. The plan was to exit if there was a loss of more than 50% for LUNA. When the price of LUNA was around $30, I was considering selling it all, including UST. Actually, based on the plan, I WAS supposed to sell it all. But I hesitated, thinking that there was a chance that it might recover, despite all signs pointing to further free-fall ahead. It was sunk cost fallacy at work.

When I did finally wake up from my slumber, the price was at $8-9. I sold everything. And later on, out of greed and false hope that I could recoup some of those losses, I stupidly bought some LUNA at around $0.05, and you all knew what happened after that.

Retrospect/Takeaway

It was my first crypto crash. In the last major crash, I was only an observer and I thought I would have learnt from it. I was so wrong. It was very stressful to experience it first hand and for the first time and you really need steady nerves and calm mind to do the right things.

I had a plan, but my discipline to follow through with the plan failed. My emotion is the weakest link. You can make all the plans you want, but when the crunch comes and you could not execute, it is pointless.

Another thing learnt is don’t be greedy. Most of the time when you are too greedy, you lose more.

The fortunate thing is that because I had done my research and knew what risks of I am getting into, UST and LUNA did not constitute a major part of my portfolio, hence losses were limited.

There were two questions that I had been pondering about since I started my crypto journey and perhaps it might be answered this time.

  • Is it better to stake or earn/keep in CEX (Centralized Exchange)?
  • Compensation/Airdrops for staked coins vs coins in CEX?

Staked coins might not be easy to exit as compared to coins store in centralized exchanges. But in the event of compensation, in the case of LUNA, you will be the first to get airdrops but for coins in exchanges, you probably might get nothing at all.

That is why I am pleasantly surprised that Hodlnaut supports the new Terra Network airdrop.

Hodlnaut Supports the New Terra Network (LUNA) Airdrop

To my knowledge, they have been the only one that supports it and throughout this Terra Luna fiasco, they have been very professional and provide clear and timely updates. Major exchanges should be learning from them. Am certainly very impressed and I think they have a bright future ahead.

Moving forward

I still believe that there is future in crypto and it is just the beginning. However, we have to be realistic and looking at the path it took for internet to be part of our day to day life, it will be a rough journey ahead.

The lessons learnt today, I hope, would allow me to avoid making even more costlier mistakes in the future. Life is an on-going learning experience. And always remember, invest what you can afford to lose and always, always remember, there is more to life than dollars and cents.

If you are curious on what caused and how TerraUSD (UST) came to de-peg, you can check out the link below.

Nansen – On Chain Forensics: Demystifying TerraUSD De-peg

Day to Day

Happy Bitcoin Pizza Day and Thank You Coinhako!

Almost 12 years ago, a programmer was craving pizza. So, he bought two pizzas. What made it unique was that he paid for them in Bitcoin, the first-ever real-world transaction using cryptocurrency. 10,000 BTC was traded for 2 pizzas, imagine how much 10,000 BTC is worth right now! As at the time of writing, 1 BTC is worth SGD$ 41,487 or USD$ 30,072.20. You work out the math how much 10,000 BTC is worth now.

And thank you Coinhako for having the Bitcoin Pizza day contest! Love the prize very much!

Check out Coinhako – The platform to buy, sell and store your crypto assets. https://www.coinhako.com/affiliations/sign_up/173349_36362274

Coding, Day to Day

Business Central – CLEAR vs INIT function

What is the difference between CLEAR and INIT functions? Clear(Record) vs Record.Init()

CLEAR function

When used on a variable, i.e. Clear(SomeVariable), it simply clears the value that is stored to its default state. For example if it is a number variable, it will be set to 0 (zero), a date variable to undefined date (0D) and so on. Clear can be used on a Guid data type, and in this case sets the GUID to all zeroes.

When used on a record, i.e. Clear(Rec), or an array, all elements are cleared. It resets all the filters, resets the primary key and all fields will be initialized based on the InitValue property. If ChangeCompany is used, it will reset back to the original company.

INIT function

Used for initializing a new record in a table for insertion. It will assign default values to all the fields in the record, including the SystemId field.

Both of these functions might seem to be doing the same thing, setting fields to their default state, but they are used under different circumstances for different purposes.

Day to Day

Coinhako – Minimum Earn Amount

Coinhako doesn’t seems to have a FAQ on the minimum amount of crypto that is needed for their Earn feature. Hence, I have consolidated a list here for easy reference. Hope it helps.

Coinhako Earn Minimum Limit

CryptoMinimum Limit
BTC – Bitcoin0.00175
ETH – Ethereum0.02325
DAI – DAI stablecoin10
AVAX – Avalanche0.5
AXS – Axie Infinity0.1
BNB – Binance Coin0.1
CRV – Curve10
DOGE – Dogecoin100
DOT – Polkadot2.77
GRT – The Graph10
KSM – Kusama0.1
LINK – Chainlink1
SAND – The Sandbox Token1
SOL – Solana0.55
USDC – USD Coin10
USDT – Tether10
XLM – Stellar Lumens100
XTZ – Tezos1
ZIL – Zilliqa1666.67
Updated as on 22 May 2022

Check out Coinhako – The platform to buy, sell and store your crypto assets. https://www.coinhako.com/affiliations/sign_up/173349_36362274

Day to Day, Reviews

Coinhako – Doufu’s First Foray into Crypto-land

Coinhako was my first foray into the crypto rabbit hole, by some twist of fate as Crypto.com had been my first choice. Regardless, I found it fortunate that I had signed up with Coinhako as it was an easier platform for beginners and had most success with my trade using that platform.

Coinhako Logo on Coinhako Blog

What is Coinhako?

Coinhako is a wallet and crypto exchange based in Singapore, co-founded by Singapore entrepreneurs, Liu Yusho and Gerry Eng, in 2014. It was originally created to provide a simple and hassle-free way to access Bitcoin and over the years, they have expanded to a wide variety of cryptocurrencies.

They provide one of the most accessible platforms for retail customers to buy, sell, hold, trade and swap cryptocurrencies securely. They also offer an earn feature this year for a variety of cryptocurrencies to allow customers to maximize their crypto holdings. in addition, they allow for multi-payment solutions, like bank transfers, credit card payments and GrabPay.

Coinhako is available on web browsers, Apple App Store and Google Play store, in both Singapore and Vietnam.

How I ended using Coinhako first

My brother introduced me to the world of crypto “investment” after he recommended me to sign up for a Crypto.com account. I was unable to sign up as they had stopped all new account registrations in Singapore to comply with the local laws and regulations and their KYC (Know your customer) approval process was problematic. Not wanting to miss out any opportunities and FOMO-ing, I jumped on the crypto bandwagon with Coinhako and have been using it ever since.

What I liked

  • User friendly and easy to use interface
  • Have a crypto news section which is clean and not cluttered
  • Wide variety of cryptocurrencies available for trading
  • Hassle free fiat on/off ramp
  • Singpass KYC available
  • Monetary Authority of Singapore (MAS) regulated
  • Reward points and events to get free crypto
  • Can earn interest on your crypto (Just launched this year!)

What can be improved on

  • High trading/transaction fees at 1%
  • Unclear Earn feature requirements (i.e. Minimum amount required)
  • Limited number of coins/tokens with Send and Receive feature

Thoughts and Views

Coinhako is highly recommended for someone who is just starting out on crypto, despite the high trading fees at 1%. It is a suitable platform for someone to get a feel of things works and not that intimidating. The 1% fee, if you are comparing with Gemini’s mobile fees, don’t seems too much at all. The last I remembered, Gemini seems to be charging more if you are trading via the mobile platform.

Account creation and setting up is a breeze too. Using Singpass for KYC is a walk in the park and setting up bank transfer account is straightforward, you don’t even need to go through the extra step of getting a Xfers account. It is very straightforward and best of all, it is MAS regulated. They also have a reward system and events that give you free crypto and their latest earn feature is a much awaited addition.

Of course, they do have some areas that could be worked on. For one, there ain’t much variety of crypto that you can send and receive to/from other wallets. Most of them are only available for trading (buy and sell). On the whole, it is worth your consideration if you are just starting out on your crypto adventures.

Check out Coinhako – The platform to buy, sell and store your crypto assets. https://www.coinhako.com/affiliations/sign_up/173349_36362274

Day to Day, Thoughts

Is this Web 3.0?

I was reading up on Web 3.0 few months ago and the search results were mostly blockchain technologies, decentralization and cryptocurrencies, especially Polkadot, due to its relationship with Web3 Foundation. Hidden beneath this huge pile of digital coins and tokens, there was a brief mention on distributed web via IPFS. That caught my interest. Will it be possible to host my own web server/web site from my own computer at home again?

What is IPFS?

IPFS stands for InterPlanetary File System. ( Don’t ask me why interplanetary, I have no idea. 😀 ) It is a peer-to-peer network protocol used for storing and sharing data in a distributed file system. IPFS uses content addressing to uniquely identify each file, akin to using a hash as an identifier. For every change that the file has, its hash or identifier will also change.

IPFS implementation on how users host and receive content is similar to BitTorrent. Any user in the network can server the file by that content address and other peers can find and request it from any nodes who has it. The difference between IPFS and BitTorrent is that IPFS aims to create a single global network while BitTorrent is more focused on distributing data and files in a decentralized manner. To access an IPFS site, you either have to install an extension or use the Brave browser or view through a public gateway. You can check out the official website of IPFS to find out more.

The alternative to IPFS would be Hypercore Protocol. For this, you will need the Beaker browser to access the sites. I had not read up on this yet so I cannot comment. There used to be Opera Unite if you just want to host a static website from your home computer but it has been discontinued. However, you can try your luck by downloading older versions of the Opera browser as some people have claimed to have gotten it to work.

If you are going to get your hands dirty with IPFS, Unstoppable Domains and Pinata deserves a mention.

What is Unstoppable Domains

Unstoppable Domains is a domain service for the decentralized web by building blockchain-based domain names. It is quite similar to the ETH naming services. The idea is similar to owning a domain name for your website, example “mywebsite.com”, except in this case, it goes beyond owning a name for your website. You can link it to your crypto wallet addresses, so instead of sending your coins to a hash address, you can send it to your address like “someone.crypto”. The best part is, unlike traditional domain subscription which you have to pay annually, this is a one time payment.

However, it is not so straightforward like signing up and get the unique address you have chosen. You will need a crypto wallet (i.e. metamask) and to mint the address, then update the relation/link to your IPFS and wallet address to the blockchain. Not to worry though, their guide and FAQ are very clear and easy to understand.

Visit Unstoppable Domains for more information.

What is Pinata

Pinata is a pinning service that allows users to host files on the IPFS network. Pinning services have IPFS nodes that are always online so you do not have to worry that there will be scenarios that there are no nodes hosting your data. The more nodes you have, the better it is.

Pinata offers other services too. You can check out Pinata website for more information.

Trying out IPFS

There were a lot of guides and how to articles online, so stepping up IPFS and hosting your site wasn’t as difficult as I thought. I did have to read up a lot on the IPFS, Pinata and Unstoppable domain websites before I had any idea what I am supposed to do. That took the most amount of time actually as compared to setting up the site. I did get into some boo-boos but none are deal breakers. Below is a summary of what I had done.

  1. Build my single page static website (HTML + CSS)
  2. Install IPFS on my computer
  3. Setup the folder and copy the created HTML page
  4. Add HTML page to IPFS (it will take a while to get it up on the node)
  5. Create and setup Pinata account as an alternate node
  6. Out of curiosity, create and setup an Unstoppable Domain account

Unfortunately the domain I bought does not support IPFS website at the moment 😦

You can check out the end result here.

Thoughts on IPFS

It was certainly an eye opening and educational experience setting up my IPFS website and it also gave me a better understanding on what “Web 3.0” really is about, without the hype.

On IPFS, it was not meant for the average joe and more as an enterprise solution to store static assets and/or content to avoid network failures and DDOS attacks. As compared to hosting a normal HTML site on HTTP web servers, doing it on IPFS requires more work and technical knowledge. I had tried Opera Unite to host my own web site few years back and I could tell you that the user experience was much more user friendly than doing it on IPFS. It would certainly be more challenging and tedious to maintain a WordPress like website on IPFS. Not just that, most browsers, with the exception of Brave browser, do not support IPFS protocol out of the box, so your audience would be limited.

Thoughts on Web 3.0

I am of the opinion that Web 3 is too overhyped right now and most people do not have a clear understanding of the technology and its use cases. A lot of people believe that Web 3.0 will replace Web 2.0 and Web 2.0 technologies will be a forgotten past in the next few years. Web 2.0 is not going to be replaced and neither Web 3.0 will dominate Web 2.0 entirely. Both Web 2.0 and 3.0 will complement each other instead of fighting for dominance. Similarly we won’t have full decentralization, there will always be use cases that requires centralization to exists. There has to be a compromise at times.

The strength of Web 3.0 belongs to the backend, on how things operate under the hood, from making content delivery more resilient to providing accountability to transactions and spawning a new financial ecosystem.

Web 2.0 will play a vital role in the adoption of Web 3.0 technologies by providing the UX/UI (interface and user experience) to onboard the masses for adoption. You can have the best blockchain technologies but if you cannot provide usability for the common folks out there, it is pretty useless.

This synergy of Web 2.0 + 3.0 will open another new exciting chapter in the history of humanity. Just look at Decentralized Finance (DeFi) and Decentralized Autonomous Organization (DAO) to get an early feel of it. We are still early though but it will mature and arrive at our door step pretty soon.

Day to Day, Thoughts

Is Gold a Bad Investment?

Commodities prices tends to go up, especially during war or disaster. Gold is no exception. Gold prices rose in response to the Ukraine War amidst inflation worries. This war is unprecedented in recent history and has far reaching implications for the world and our future. One should not underestimate and label this as just another proxy war between superpowers. Having said that, we hope for peace and recovery for all.

Photo by Mathias P.R. Reding on Pexels.com

Recently, two tweets caught my attention and set me thinking about gold as part of one’s portfolio. Peter Schiff lamented in his tweet that gold was up above $2,050 for the first time and CNBC chose to cover Bitcoin which was trading below $39,000. Meanwhile, James from MoneyZG mentioned in his tweet that gold is a waste of time as a good “hedge” because you need a war for it to go up, and as a result, 1% of your portfolio is up while the rest is down.

So who is right? It depends.

Before we continue, let us understand and accept the assumptions, biases and context for this article. I have purchased both gold and cryptocurrency assets and I am impartial to both. This article was written from the aspect of the common folks (the average joe/jane, not some financial guru/expert or seasoned investor or trader) in Singapore, though some of the content might relate to overseas audiences. The article written here are based on my personal thoughts and opinions, they do not constitute or meant to be used as financial advice.

Where to buy gold in Singapore?

Photo by Alizee Marchand on Pexels.com

Let us briefly look at some options to purchase gold in Singapore.

Jewellery / Physical Gold (Retail)
The most accessible option. You can head into any jewellery or pawn shop to buy them but do note that not all jewellery are in the form of pure gold. Jewellery might be more expensive than gold bar or coins due to the additional craftsmanship charges. For pure physical gold, you can walk into a gold retailer to buy gold bars or bullion coins. While you can hold it physically in your hands and admire them, you have to consider where to keep it safely.

Gold Exchange Traded Fund (ETF)
Instead of buying physical gold and have a headache over storage and security concerns, you can invest in gold through an ETF that owns, holds and derives its value from holding physical gold. ETFs, like STI ETF or S&P500, have been providing cost-efficient investment solution for the average person. You can consider SPDR Gold Share ETF that is listed on the SGX. You will need a brokerage and a CDP account as a pre-requisite though.

Gold Savings Account
“Eh? Got this kind of things meh?” Yes, but unlike regular savings account, no interest are given out. It offers an easier way to buy and sell gold without worrying about storage and security issues. UOB provides such services but it comes with extra charges. I would recommend using HugoSave. It is much easier and cheaper to use as compared to UOB. You can check out my experience with HugoSave via the links at the bottom of this article.

Cryptocurrencies
Bitcoin? Oh no no no, not this 😀 We are not referring to that digital “gold” but cryptocurrencies pegged to commodities. Similar to stablecoins where 1 coin is peg to 1 US dollar, 1 PAX Gold – PAXG token is backed by one fine troy ounce (t oz) of a 400 oz London Good Delivery gold bar, stored in Brink’s vaults. If you own PAXG, you own the underlying physical gold, held in custody by Paxos Trust Company. So if you are already knee deep in crypto land, this can be another option for you.

But what makes this option interesting is that if you hold it in either Crypto.com or Gemini, you can park it under their Earn feature to earn interest (starting from 0.5% APY at this time of writing). This is something that is not possible for the above options, but it is more risky.

Photo by Startup Stock Photos on Pexels.com

Why gold?

Gold is a precious metal that has been around for centuries and is universally accepted as an alternative to money. Besides its role as an investment, it is also a raw metal for electronic products such as computer processors. Some people believe it to be a good hedge against inflation. Gold is a tangible asset which you can own physically as compared to stocks, bonds or Bitcoin. It is global accepted and recognized, you can use it anywhere. And it looks really nice and shiny.

Why not gold?

Long term returns tend to be poor, and safely storing physical gold can be difficult. It will not provide a steady source of income like dividend stocks. If you own a gold bar for 30 years, you still own the same gold bar. It might be more “expensive” as compared to 30 years ago but that is because the value of the dollar has gotten smaller. If you own a company stock for 30 years, there is a chance that it will worth X times more. In a way, you are losing out the opportunity to make more money if you bought gold instead of Apple stocks. Contrary to popular beliefs, some people think it is not a good hedge against inflation.

Scenarios

Photo by Pixabay on Pexels.com

Let’s have a very simplistic assumption here. Imagine we are in stagflation, war is raging in Europe and there are food supply shortages. No one knows when good days are coming.

Assume that we have Portfolio A which has 5% Gold and Portfolio B which has 5% Bitcoin. None of the portfolios have both Gold and Bitcoin. Both portfolio have equal ratio of Cash, Stocks and Bonds. Here are some questions to ask for each of the scenarios listed below.

Scenario #1 – Something happened and you need a lot of cash urgently

  • Would having gold in Portfolio A give you more options and flexibility in liquidity?
  • Are you fine with selling your stocks or Bitcoin that are in the red, at a loss in Portfolio B?
  • Are you really comfortable in doing the above to get the cash?

Scenario #2 – The stock or cryptocurrency that you have conviction is at a good price

  • Would having gold in Portfolio A give you more options/confidence to buy the dip?
  • Are you fine with selling your stocks (at loss) or using cash in Portfolio B to buy the dip?
  • Are you really comfortable in doing the above, not knowing how long this will go on?

Scenario #3 – Fiat/Cash is basically worthless

  • Would having gold in Portfolio A give you more confidence in making it out alive?
  • Would having Bitcoin in Portfolio B give you more confidence in making it out alive?
  • Would having both Gold and Bitcoin be better in this scenario?
Photo by Vie Studio on Pexels.com

Yes, or No to Gold? That is the question.

It really depends on what you want, your goals, and your risk appetite. I think the most important thing is to know what you are doing and your expectations. For some people, it is alright not to have gold in their portfolio while others prefer some form of security. There are no right or wrong answers, just what matters for the individual.

To me, the role of gold in my portfolio is not to generate revenue for me but to serve as an insurance, especially in an emergency. I have never expect investing in gold is going to make me rich and I think it is unrealistic to assume that. So far, I have not heard anyone who got rich by from gold investment alone. Instead, those millionaires or billionaires made their riches, then they buy gold as an “investment”. If you think deeper, do you really think that they do it to increase their wealth, or does it not seem like buying insurance instead? Food for though huh.

My opinion on gold is that it is often a better hedge against a crisis than against inflation. History has proven that gold prices tend to rise in times of crisis.

Photo by David McBee on Pexels.com

But is that the only question?

What if, god forbids, war has arrived at our shores or we are at the receiving end of sanctions? In this case, gold is only useful if you have it physically. However, you will have to deal with the issue of carrying it around and safeguarding it. The Ukraine war has shown that cryptocurrencies have a place in our modern world and it is a viable option as a currency/asset. The caveat is that this will work only if cryptocurrencies are decentralized in nature (i.e. Bitcoin). No, your coins and tokens in centralized exchanges don’t count. What matters if you can use them in offline wallets (i.e. Ledger) for day-to-day transactions that can keep your life going.

Many people tend to compare or associate Bitcoin as gold or technology stocks. It is too early to give judgement and very much unfair to limit their potential. Bitcoin and the rest of the cryptocurrencies are still at their infancies and are trying to figure out where they fit in our world. They have the potential to be an unique asset class, something that we are unable to visualize or understand for now.

At the end of the day, gold and cryptocurrencies are just tools for us to use, you have to decide which works to your best advantage.

Photo by Porapak Apichodilok on Pexels.com

Related contents from I Am Doufu

Help Ukraine

Relevant affiliate links

  • HugoSave helps me convert my spare change to gold!
  • Crypto.com is my favourite now! Sign up and we both get USD$25 $CRO!
  • Crypto Exchange is an another way to buy crypto in Crypto.com!
  • Gemini is an easy way to trade and earn crypto. Sign up to get $BTC!
  • Moomoo is my go-to trading platform! Join now for free Apple shares!
Coding, Day to Day

Business Central – How to change primary key of a record

Typically when we want to update the contents of a record in BC, we would just use the modify function. For most cases, that would suffice, but what happens if the field you want to update is part of a composite primary key? Or when updating a record in which the content to be changed includes part of a primary key? In these scenarios, using the modify function will return an error. The solution? Read on!

Sample Record Structure

Here is a sample record structure for reference. In this case, we have a composite key consisting of “Entry No.” and “Line No.” as well as other data fields.

table 55047 "Sample Line Data"
{
    fields
    {
        field(1; "Entry No."; Integer)
        {
            Caption = 'Entry No.';
        }

        field(2; "Line No."; Integer)
        {
            Caption = 'Line No.';
        }
       
        field(3; "Item Code"; Code[10])
        {
            Caption = 'Item Code';
        }

        field(4; "Item Description"; Text[50])
        {
            Caption = 'Item Description';
        }
    }

    keys
    {
        key(PK; "Entry No.", "Line No.")
        {
            Clustered = true;
        }
    }
}

So what should we do if we need to change the following data: “Line No.” and “Item Description”?

We use the Rename function to update the “Line No.” which is part of the primary key, then re-retrieve the record and update the “Item Description” using the modify function.

The syntax for Rename function as show below.

[Ok := ]  Record.Rename(Value1: Any [, Value2: Any,…])

Code example as show below.

// #1 change part of primary key, line no from 1000 to 2000
if MyRecord.Get(1,1000) then
    MyRecord.Rename(MyRecord."Entry No.", 2000); 

// #2 get record again with new key
if MyRecord.Get(1, 2000) then
    begin 
        // #3 update item description (non key field)
        MyRecord."Item Description" := 'Changed Description';
        MyRecord.Modify();
    end;

Remember, do not change the sequence of the primary key!