{Step by Step} Upload a File from Dataverse to SharePoint Using Power Automate

In this blog, we will learn how to upload a file from Microsoft Dataverse to SharePoint, in my account entity I have a custom file type column “Account File”, Flow will get triggered when user uploads file in any column.

Implementation:

  • For triggering the flow, we are using action from Microsoft Dataverse “When a row is added or modified”.
  • Select table, here we have selected “Accounts”.
  • In “Select columns” we have added a logical name of file type column.
  • Now add “Download a file or an image” action from Microsoft Dataverse.
  • Select “Accounts” in table name.
  • Add dynamic content to get GUID in Row ID.
  • And select your file type column in Column name.
  • Add a “Get a row by ID” action from Microsoft Dataverse.
  • Select table name as “Accounts”.
  • Add dynamic content to get GUID in Row ID.
  • Now add an action from SharePoint “Create file”.
  • Select the site where you want to upload the file.
  • Provide folder path.
  • In “File Name”, we have added dynamic content to get account name from trigger.
  • After adding the dynamic content just add the file type, We have added “.csv”.
  • And in “File Content” add dynamic content of “File or Image Content.”



Output:

Hope it helps! 

Power 365ing as usual! 

Any requirements, implementation or consulting work in Power Platform or Dynamics 365 – end user, Microsoft partner or an individual? 

Problem Area – Technical, Functional, Training, Development or consulting? 

Me and my team are here to assist, please fill the following form for your business needs: Click here 

{Code Tip} How to check Quick Create form type via JavaScript in D365 CE

In this blog post, we will learn how to check the Quick Create form type by using JavaScript. Quick-create forms are a convenient way to create new records without leaving the current page. 

Requirement

To perform logic or validation based on the form type, we need to get the form type value.

To distinguish between create and quick create forms, we can use JavaScript.  

In the present scenario, I will show how to create a contact from the Account entity using the quick create form and then Auto-populate the field ‘Job Title’ as ‘Developer’.  

Implementation:

  • To implement this requirement, we are using java script.
function GetFormType(excecutionContext)

{
//Get the form Context.
var formContext = excecutionContext.getFormContext();

//To get the Context object
var contextObject = excecutionContext.getContext();

//To get the form type via getQueryStringParameters()
var formType = contextObject.getQueryStringParameters().pageType;
//to check is available form is type Quick Create
if(formType == "quickcreate" && formContext.getAttribute("jobtitle") != null)
{
//To set the 'Job Title'
formContext.getAttribute("jobtitle").setValue("Developer");
}
}

Output:

Hope it helps! 

Power 365ing as usual! 

Any requirements, implementation or consulting work in Power Platform or Dynamics 365 – end user, Microsoft partner or an individual? 

Problem Area – Technical, Functional, Training, Development or consulting? 

Me and my team are here to assist, please fill the following form for your business needs: Click here 

{Code Tip} Set a Default View on a Lookup Conditionally using JavaScript

In this blog post, we will learn a new code snippet of JavaScript that we are using to implement a requirement in a Model Driven App. The feature is called “setDefaultView()”, and it allows us to dynamically change the default view of a lookup field.

Requirement:

Filter the lookup values of the contact entity on the account entity based on the selected option in the ownership column. The ownership column is an option set type column with four options:

  • Public
  • Private
  • Subsidiary
  • Others

We want to show only the contacts that belong to the same ownership type as the account in the lookup field.

Implementation:

To achieve this, we are using the setDefaultView() method of the lookup control in JavaScript. This method takes a view ID as a parameter and sets it as the default view for the lookup field. We can use this method in the OnChange event handler of the ownership field to dynamically change the default view of the contact lookup field based on the selected option.

  • We have an option set column of “Ownership”.
  • Based on the options, we have created views.
  • And we have a lookup column of contact entity.
  • Also, we have an option set column of ownership on Account entity .
  • If value in ownership is selected as “Public”, only public view records will be suggested in lookup.

//Option set Values of "Ownership" field.
const Ownership = {
PUBLIC:1,
PRIVATE:2,
SUBSIDIARY:3,
OTHER:4,

};

//To set the Custom View on Lookup Field.
function SetDefaultViewOnContact(executionContext)
{
var formContext = executionContext.getFormContext();
if (formContext.getAttribute("ownershipcode") != null && formContext.getAttribute("ownershipcode").getValue() != null)
{
//To retrive the "Ownership" of current record.
var OwnershipAcc = formContext.getAttribute("ownershipcode").getValue();
switch(OwnershipAcc)
{
case Ownership.PUBLIC:
formContext.getControl("primarycontactid").setDefaultView("{13E3DEA0-09C0-EE11-9079-000D3A337001}");
break;
case Ownership.PRIVATE:
formContext.getControl("primarycontactid").setDefaultView("{48AEAFA1-0BC0-EE11-9079-000D3A337001}");
break;
case Ownership.SUBSIDIARY:
formContext.getControl("primarycontactid").setDefaultView("{CB830663-17C0-EE11-9079-000D3A337001}");
break;
default:
formContext.getControl("primarycontactid").setDefaultView("{608861BC-50A4-4C5F-A02C-21FE1943E2CF}");
}
}
}

This way, we can provide a better user experience and filter out irrelevant lookup values based on the context. The setDefaultView() method is a new feature of JavaScript that is available in Model Driven Apps and can be used for various scenarios where we need to dynamically change.

Output:

Hope it helps! 

Power 365ing as usual! 

Any requirements, implementation or consulting work in Power Platform or Dynamics 365 – end user, Microsoft partner or an individual? 

Problem Area – Technical, Functional, Training, Development or consulting? 

Me and my team are here to assist, please fill the following form for your business needs: Click here