A clean and nice way to convert datetime from UTC to specific time zone using AT TIME ZONE.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-AzApiManagementApi : Value cannot be null. Parameter name: source At line:1 char:1 + Set-AzApiManagementApi -Context $ApiMgmtContext -ApiId $ApiId -Subscr ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (System.Argument...ExecuteCmdlet():ArgumentNullException) [Set-AzApiManagementApi], ArgumentNullException + FullyQualifiedErrorId : Value cannot be null. Parameter name: source,Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.SetAzureApiManagementApi
After a number of trial and error tests, I found that the missing parameter is '-Protocols'.
So the final script that worked was:
$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName $ResourceGroup -ServiceName $ApimName Set-AzApiManagementApi -Context $ApiMgmtContext -ApiId $ApiId -Protocols @('https') -SubscriptionKeyQueryParamName "auth-key" What interesting is that the documentation at https://docs.microsoft.com/en-us/powershell/module/az.apimanagement/set-azapimanagementapi?view=azps-3.7.0 does not mention -Protocol is a required parameter.
The allowed time of the exam is 180 minutes. And it took me 140 minutes to complete.
I would say it was not an easy exam for me who already have pretty much practical experience, and who been working with Azure day in day out in my past and current projects.
I faced the following error today when logging in Salesforce Dev Hub using the CLI.
'EACCES': listen EACCES 127.0.0.1:1717
And what I did to get over it was to change that default port 1717 to something else.
The steps are as below.
Open a Command Prompt window.
Go to a folder in your local machine using cd command. For example, in my case: cd Samples\Salesforce\my_sfdx_project
Create a Salesforce DX project using sfdx force:project:create command. In my case: sfdx force:project:create -n force-proj01
In the newly created folder force-proj01, open sfdx-project.json file and add following line: "oauthLocalPort": "7717",. The file will eventually contain:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In this post I will give an example in a real life scenario when this feature will be used. That is the scenario when a field in an entity needs to be numerically auto-generated with a particular pattern.
Auto number in Salesforce vs Dynamics 365
In Salesforce, auto-number is an out of the box feature when defining an object, as in the image below.
Another approach, which is the purpose of this post, is to build a custom plugin that will generate the next sequence number for the field in question.
Auto number custom plugin
In this approach we will create an entity, named as autonumber_config, that will centrally manage the sequence number and number format for a list of several fields in one or more entities. That is also the advantage of this approach over the built-in one where the auto number is configured individually in each field/entity.
The autonumber_config entity will have following fields.
entity_name
field_name
field_format
next_number
The logic for this plugin is that, whenever a record is created in the target entity that the plugin is registered to, the plugin will query the respective record in autonumber_config entity to obtain the current value of next_number field, then increase it by 1 and update back to the autonumber_config entity. The value of next_number field, together with field_format field, will be used to generate the actual auto-number for the target field in target entity.
Now comes the issue. When multi users try to create a new record of the same entity at the same time, there will be chance that the same next_number value will be obtained for multiple records.
That is when optimistic concurrency comes into play. The idea is that, after the plugin has obtained a next_number value, when updating the new value back to the record it will use the UpdateRequest with the ConcurrencyBehavior set to ConcurrencyBehavior.IfRowVersionMatches. If request is successful, the next_number value can be used as a valid number.
If a FaultException exception thrown back from service with ConcurrencyVersionMismatch (code=-2147088254) then it means that the record has been updated by another user. In that case the plugin will try to increase next_number value by 1 and update again. This can be repeated until a new next_number value can be updated.
Enough talk, time for code. Below is the main part in the Execute method of the plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Unfortunately it does not provide a sample code (in C#) for how to compose the batch request and handle respective response.
So here is the one that I have built for my project:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The SendBatchRequestAsync method has two overloads which can be used for two different scenarios:
Execute a batch request that is composed of a list of individual requests, each of them can be in turn a change set, or
Execute a list of requests that are grouped into a single change set.
Example 1:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters