Wednesday, August 21, 2024

Package export Api through logicapp

 Scenario:-Exporting  data package from d365fo

I got a requirement where I need to Export d365fo data package of Customersgroup data to OneDrive

Step1:-Create a data export project in d365fo

Step2:-Create logic app and choose Recurrence as trigger point for logicapp. I have set it for one day but will fire manually.

Step3:-Take http connector and use export to package URL

Post:-d365url/data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.ExportToPackage

In body :-

{ "definitionGroupId":"<Data project name>", "packageName":"<Name to use for downloaded file.>", "executionId":"", "reExecute":true, "legalEntityId":"<Legal entity Id>" }

Step4:-Put delay so that datapacakages need to be exported

Step5:-Use parse json under data operations by and  put previous http output as sample payload

or else paste this code

{ "@odata.context":"https://<baseurl>/data/$metadata#Edm.String", "value":{ "value":"<executionId>" } }

Step6:-Use another http now to get exportedpackageurl

POST /data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.GetExportedPackageUrl BODY {"executionId":"<Execution Id>"}

Step7:-Use parse json to use this output in next http connector

Step8:-Till now I got exported package URL itself now I need file to send

URL will be previous http Output this is why I taken parse json and no body

Step9:-Now I need to send this file to OneDrive

Step10:-Fire logicapp manually then after few minutes you will be able to see file added in OneDrive

Step11:-Open the file and download

Step12:-Now you can see file downloaded in local desktop

Step13:-Open excel file and see data 

Note:-You can see extra two files like manifesto and Package header files as it is a data package it contains Don't Worry

Keep Daxing!

Tuesday, August 20, 2024

Package Api Import through logicapp

 Scenario :-Import from package 

I got a requirement where I will get datapacakages added in blob so I need to import data in d365fo 

Step1:-Create a data project in d365fo using Datamangement

Note:-Add a sample file for the project.



Step2:-Create a Workflow in logicapp in AZURE. So my trigger point will be blob modify as my datapacakages will be added in blob storage


Step3:-Take next action as Blob and take function as create sas URL by path 


Step4:-Now take http and use method as post and URL will be

D365fourl/data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.

ImportFromPackage




Step5:-To check the status of package imported successfully parse the previous output 

Step6:-Now use http to get status from d365fo

Note:-Use delay because instantly we cant check We need to give some time to import in D365fo




Step7:-One can see logic app run history once we get a data package added in blob



Step8:-Save Logicapp and wait for file to be added in blob once we get datapacakages added in blob

you can see record inserted in d365fo.If we have records already it will get updated.


      keep Daxing!

 
























Monday, August 12, 2024

Postman testing odata with D365fo

 Step 1:- Generate bearer token  

Note:-For every one hour  generate new bearer token to avoid authorization error.

 

Get :-https://login.microsoftonline.com/tenantid/oauth2/token 

 

Body:- formdata 

 

a) tenant_id – 

b) client_id –  

c) client_secret –  
d) grant_type – client_credentials 
e) resource – enter D365FO environment URL (note it should not end with /) 

 

Output:- 

{ 

    "token_type": "Bearer", 

    "expires_in": "3599", 

    "ext_expires_in": "3599", 

    "expires_on": "1723463000", 

    "not_before": "1723459100", 

    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IktRMnRBY3JFN2xCYVZWR0JtYzVGb2JnZEpvNCIsImtpZCI6IktRMnRBY3JFN2xCYVZWR0JtYzVGb2JnZEpvNCJ9.eyJhdWQiOiJodHRwczovL3RyaWFsLXpwZ3l2ay50cmlhbC5vcGVyYXRpb25zLmR5bmFtaWNzLmNvbS8iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9jYTA2YTExMC1mYzMwLTQ3ZTUtOWRkNC03MThkNWQ0YzQyNDQvIiwiaWF0IjoxNzIzNDU5MTAwLCJuYmYiOjE3MjM0NTkxMDAsImV4cCI6MTcyMzQ2MzAwMCwiYWlvIjoiRTJkZ1lEaW5WelN6T2o1LzZaSHN2Y212UHA0eEFnQT0iLCJhcHBpZCI6IjQ5ZjAxNWI5LWQ1MzMtNDdlNi1iYTI2LTc3MGZlMTU3Y2NjMyIsImFwcGlkYWNyIjoiMSIsImlkcCI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0L2NhMDZhMTEwLWZjMzAtNDdlNS05ZGQ0LTcxOGQ1ZDRjNDI0NC8iLCJpZHR5cCI6ImFwcCIsIm9pZCI6IjYyNGE1MDBiLTk3ODItNDk1ZC1hMWQ1LTc4YTNkYTg2MTg2OSIsInJoIjoiMC5BU29BRUtFR3lqRDg1VWVkMUhHTlhVeENSQlVBQUFBQUFBQUF3QUFBQUFBQUFBQXFBQUEuIiwic3ViIjoiNjI0YTUwMGItOTc4Mi00OTVkLWExZDUtNzhhM2RhODYxODY5IiwidGlkIjoiY2EwNmExMTAtZmMzMC00N2U1LTlkZDQtNzE4ZDVkNGM0MjQ0IiwidXRpIjoiZXdQWWU3S2hoVXllS0dURGgtS1VBQSIsInZlciI6IjEuMCIsInhtc19pZHJlbCI6IjcgMiJ9.kNDAndZRZgwN-78gPl3aSHW-A7am5hSALHrqDJpwJBITgXePf2BtbqkyMYV6H_T_vlCp2nCymEFrSbJJFihGQ1f5xiuth9vjLasSm1sH5mK2Gr8t7Y78YEdjYnABI0NIIrHBug__aEGdB-eAd7zBmI_rZ9f1ca4UBHxlrjskZCB6hoEjO44v0_eisWTwU5o6no6GI8ZrpAbDiNkqpiZMwwfh6JJfm9SQwq1k_rTFhyGQ8lg19zofxy4l29IMw4-kwTqQYN5_JeEiZCxVbsJ2WjUJpLzKNpabyDe859Vr9HQe1MwSAZHfgvvPF3020po9hrhznewHkOGmKKOGZyzrNQ" 

} 

 

 

Step 2:- To get data use method GET 

 

 

Eg:-Output as below 

{ 

            "@odata.etag": "W/\"JzAsMjI1NjU0MjExODMn\"", 

            "dataAreaId": "demf", 

            "CustomerGroupId": "20", 

            "ClearingPeriodPaymentTermName": "Net30", 

            "DefaultDimensionDisplayValue": "", 

            "CustomerAccountNumberSequence": "", 

            "AccountingCurrencyExchangeRateType": "", 

            "IsSalesTaxIncludedInPrice": "No", 

            "Description": "Major customers", 

            "WriteOffReason": "", 

            "ReportingCurrencyExchangeRateType": "", 

            "PaymentTermId": "Net30", 

            "TaxGroupId": "", 

            "IsPublicSector_IT": "No" 

        } 

Step 3:-To insert new record  

Post:-https://trial-zpgyvk.trial.operations.dynamics.com/data/CustomerGroups?cross-Company=true 

Body:-Previous get method output 

{ 

                      "dataAreaId": "demf", 

            "CustomerGroupId": "111", 

            "ClearingPeriodPaymentTermName": "Net30", 

            "DefaultDimensionDisplayValue": "", 

            "CustomerAccountNumberSequence": "", 

            "AccountingCurrencyExchangeRateType": "", 

            "IsSalesTaxIncludedInPrice": "No", 

            "Description": "Major customers", 

            "WriteOffReason": "", 

            "ReportingCurrencyExchangeRateType": "", 

            "PaymentTermId": "Net30", 

            "TaxGroupId": "", 

            "IsPublicSector_IT": "No" 

        } 

 

Output:- 


 

 

Step 4:-To update a record 

Patch:-https://trial-zpgyvk.trial.operations.dynamics.com/data/CustomerGroups(dataAreaId='usmf',CustomerGroupId='111')?cross-company=true 

 

Body:- 

{ 

    "dataAreaId": "usmf", 

            "CustomerGroupId": "111", 

             

            "AccountingCurrencyExchangeRateType": "", 

            "IsSalesTaxIncludedInPrice": "No", 

            "Description": "manikanta", 

            "WriteOffReason": "", 

            "ReportingCurrencyExchangeRateType": "", 

            "PaymentTermId": "Net30", 

            "TaxGroupId": "", 

            "IsPublicSector_IT": "No" 

} 

 

Output:- 


 

Step 5:-Put method is also used to update but whatever fields which we are updating will updated and rest will considerd as null values 

 

Put:-https://trial-zpgyvk.trial.operations.dynamics.com/data/CustomerGroups(dataAreaId='usmf',CustomerGroupId='111')?cross-company=true 

 

Body 

 

{ 

    "dataAreaId": "usmf", 

            "CustomerGroupId": "111", 

             

                        "PaymentTermId": "Net30", 

           } 

 

Output:- 

 


 

Step 6:-To delete a record 

Delete:-https://trial-zpgyvk.trial.operations.dynamics.com/data/CustomerGroups(dataAreaId='usmf',CustomerGroupId='111')?cross-company=true 

Body:- no body required 

Output:- 

 


 

 

 
 
 

 

 

 

computed column in Dataentity

synatx:-    public static server str methodname()   {       str purchid=SysComputedColumn::returnField(dataentityviewstr(Dataentityname),d...