Parag Chapre

How to use D365 F&O number sequence in Power Platform

How to use D365 F&O number sequence in Power Platform

Using continuous number sequences from Dynamics 365 Finance and operations in Power Platform can be cumbersome sometimes but in today’s article we will see how to use it.

What is number sequence

Number sequences are used to generate readable, unique identifiers for master data records and transaction records that require identifiers. A master data record or transaction record that requires an identifier is referred to as a reference.

If you want to use Dynamics 365 F&O number sequences outside Dynamics, we mostly use Odata, dataverse etc. It depends on what technology you are using. For example, if you are trying to create a customer or vendor through Power Platform, we can use Odata or Dataverse.

Common Issue

You cannot generate the number sequence from Power Platform due to mandatory fields in the D365 F&O entity.

You will receive an error.

Message”: “Write validation failed for table row of type ‘YourEntity‘. Infolog: Warning: Field ‘Id‘ must be filled in..”

How to resolve number issue in Power Platform

Step 1: I have created a table which has a number sequence field VoyageId, and this field is mandatory at table level. You can also use existing table which has number sequence and mandatory field.

Step 2: Make sure your entity is set public to Yes.

Step 3: First check whether your entity has initValue method.

Option 1- No, just copy and paste below code snippet and change accordingly to your enity, field and number sequence reference.

public void initValue()
{
	if (!this.skipNumberSequenceCheck())
	{
		NumberSeqRecordFieldHandler::enableNumberSequenceControlForField(
			this, fieldNum(ProjectTaskCodesDataEntity, VoyageId), APParameters::numRefVoyageID());
	}
	
	super();
}

Option 2- Yes, if you already above code written, then just ignore it.

Step 4: Test the integration.

Before initValue method:

  1. Create a power automate.
  2. Add a manually trigger a flow
  3. Add HTTP Post Action

Method: Post

URL:https://xxxxxxxx.axcloud.dynamics.com/data/ProjectTaskCodes

Body: Your field id and values in the quotes.

Authentication: AD OAuth.

Provide Tenant, audience, client id and secret.

4. Run the Power automate.

You will receive an error message saying Project Id must be filled in

After initValue method:

  1. Write the code mentioned in Step 3.
  2. Run the Power automate.

You see the flow ran successfully.

Now, you can verify the data by going to Odata entity.

If you like this article, feel free to share it with others who might find it helpful! If you have any questions, feel free to reach out to me.

Leave a Reply

Your email address will not be published. Required fields are marked *