Load dynamic fields in Microsoft flow custom connector - power-automate

I'm creating a custom connector in Microsoft flow, it has an action so when there is a new record created in CRM i want to push it to my application using flow.
In my application i have different modules, there is a dropdown to select module in flow, on selection of module I want populate the input fields.i want to know if there is a way to achieve this. I see some existing flow connectors has this feature but i couldn't find the useful resource to implement this.

Yes you can achieve this.
If the list is static you can use the enum attribute and
if your list is dynamic you can use the x-ms-dynamic-values property to populate your input fields of any attribute.
Static dropdown example :
"action": {
"type": "string",
"description": "",
"title": "Action",
"enum": [
"Car",
"Bike"
]
}
Dynamic dropdown example :
{
name: "listID-dynamic",
type: "string",
in: "path",
description: "Select List you want outputs from",
required: true,
x-ms-summary: "Select List",
x-ms-dynamic-values: {
operationId: "GetLists",
value-path: "id",
value-title: "name"
}
}
Complete example can be viewed here :
https://procsi.blob.core.windows.net/docs/sampleDynamicSwagger.json
Here is the detailed documentation for the same :
https://learn.microsoft.com/en-us/connectors/custom-connectors/openapi-extensions#x-ms-dynamic-values

Related

Is there a way to write an Expression in Power Automate to retrieve item from SurveyMonkey?

There is no dynamic content you can get from the SurveyMonkey trigger in Power Automate except for the Analyze URL, Created Date, and Link. Is it possible I could retrieve the data with an expression so I could add fields to SharePoint or send emails based on answers to questions?
For instance, here is some JSON data for a county multiple choice field, that I would like to know the county so I can have the email sent to the correct person:
{
"id": "753498214",
"answers": [
{
"choice_id": "4963767255",
"simple_text": "Williamson"
}
],
"family": "single_choice",
"subtype": "menu",
"heading": "County where the problem is occurring:"
}
And basically, a way to create dynamic fields from the content so it would be more usable?
I am a novice so your answer will have to assume I know nothing!
Thanks for considering the question.
Overall, anything I have tried is unsuccessful!
I was able to get an answer on Microsoft Power Users support.
Put this data in compose action:
{
"id": "753498214",
"answers": [
{
"choice_id": "4963767255",
"simple_text": "Williamson"
}
],
"family": "single_choice",
"subtype": "menu",
"heading": "County where the problem is occurring:"
}
Then these expressions in additional compose actions:
To get choice_id:
outputs('Compose')?['answers']?[0]?['choice_id']
To get simple_text:
outputs('Compose')?['answers']?[0]?['simple_text']
Reference link here where I retrieved the answer is here.
https://powerusers.microsoft.com/t5/General-Power-Automate/How-to-write-an-expression-to-retrieve-answer/m-p/1960784#M114215

fetch attribute type from terraform provider schema

am trying to find out a way to fetch the attribute type of a resource/data_source from a terraform providers schema (am currently using gcp, but will be extending to pretty much all providers).
My current flow of setup
Am running the terraform providers schema -json to fetch the providers schema
This will generate a huge json file with the schema structure of the provider
ref:
How to get that list of all the available Terraform Resource types for Google Cloud?
https://developer.hashicorp.com/terraform/cli/commands/providers/schema
And from this am trying to fetch the type of each attribute eg below
`
"google_cloud_run_service": {
"version": 1,
"block": {
"attributes": {
"autogenerate_revision_name": {
"type": "bool",
"description_kind": "plain",
"optional": true
},
`
4) My end goal is to generate variables.tf from the above schema for all resources and all attributes supported in that resource along with the type constraint
ref: https://developer.hashicorp.com/terraform/language/values/variables
I already got some help on how we can generate that
ref: Get the type of value using cty in hclwrite
Now the challenge is to work on complex structures like below
The below is one of the attributes of "google_cloud_run_service".
`
"status": {
"type": [
"list",
[
"object",
{
"conditions": [
"list",
[
"object",
{
"message": "string",
"reason": "string",
"status": "string",
"type": "string"
}
]
],
"latest_created_revision_name": "string",
"latest_ready_revision_name": "string",
"observed_generation": "number",
"url": "string"
}
]
],
"description": "The current status of the Service.",
"description_kind": "plain",
"computed": true
}
`
7) so based on the above complex structure type, I want to generate the variables.tf file for this kind of attribute using the code sample from point #5, and the desired output should look something like below in variables.tf
`
variable "autogenerate_revision_name" {
type = string
default = ""
description = "Sample description"
}
variable "status" {
type = list(object({
conditions = list(object({
"message" = string
"reason" = string
"status" = string
" type" = string
}))
"latest_created_revision_name" = string
"latest_ready_revision_name" = string
"observed_generation" = number
"url" = string
}))
default = "default values in the above type format"
}
`
The above was manually written - so might not exactly align with the schema, but i hope i made it understood , as to what am trying to achieve.
The first variable in the above code is from the first eg i gave in point #3 which is easy to generate, but the second eg in point #6 is a complex type constraint and am seeking help to get this generated
Is this possible to generate using the helper schema sdk (https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2#v2.24.0/helper/schema) ? along with code eg given in point #5 ?
Summary : Am generating json schema of a terraform provider using terraform providers schema -json, am reading that json file and generating hcl code for each resource, but stuck with generating type constraints for the attributes/variables, hence seeking help on this.
Any sort of help is really appreciated as am stuck at this for quite a while.
If you've come this far, then i thank you for reading such a lengthy question, and any sort of pointers are welcome.

How to use "anyOf" in JSON schema validation which is using RAML and MULE API?

I need to implement schema validation for incoming JSON payload.
The below elements will be there in the JSON,
"partyId": {
"type": ["string","null"],
"maxLength": 16,
"required": false,
"description": "Party ID"
},
"erpId": {
"type": ["string","null"],
"maxLength": 20,
"required": false,
"description": "ERP ID"
}
Required validation :
Any one element should be available in JSON, Else it should reject the request.
My project is using "$schema":"http://json-schema.org/draft-06/schema#"
Some follow up question?
How to find which schema draft version using in my project (some schema json file there is no draft version in the top)?
Which maven dependency is supporting this schema draft version ?
the required keyword takes a list of property names, not a boolean. It should live at the same level as "type": "object" and "properties".
https://json-schema.org/understanding-json-schema/reference/object.html#required-properties
you can use anyOf to check for the availability of any of a multiple number of properties.
https://json-schema.org/understanding-json-schema/reference/conditionals.html

Pass collection into custom angular schematic?

I want to create a custom angular schematic that can accept a collection of action names. I will then generate 3 ngrx actions for every action name provided from the user.
for example I want to create a schematic that can be invoked like this:
ng g my-collection:my-schematic --actions=GetById,GetByFirstName
Then I'll generate code for GetById, GetByIdSuccess, GetByIdError, GetByFirstName, GetByFirstNameSuccess, GetByFirstNameError.
The issue is I've only seen angular schematics that will accept a single value as an input parameter. Anyone know how to handle collections in a custom angular schematic?
you can follow this blog, it will teach you how to create your own schematics project:
https://blog.angular.io/schematics-an-introduction-dc1dfbc2a2b2
after you generate your schematics project in file collection.json you can extend the #ngrx/schematics:
{
...
"extends": ["#ngrx/schematics"],
}
and then use the ngrx schematics to generate 3 actions like this:
externalSchematic('#ngrx/schematics', 'action')
I haven't found a good example of how to an array of string into a schematic parameter, but I found a workaround. What I did was have a simple string input parameter that is consistently delimited (I used , to delimit the values). Here is my schema:
export interface Schema {
name: string;
path?: string;
project?: string;
spec?: boolean;
actions: string;
__actions: string[];
store?: string;
}
I parse the actions param that is provided and generate the string array __actions and use that property in my templates. Here is a snippet from my index.ts:
export default function(options: ActionOptions): Rule {
return (host: Tree, context: SchematicContext) => {
options.path = getProjectPath(host, options);
const parsedPath = parseName(options.path, options.name);
options.name = parsedPath.name;
options.path = parsedPath.path;
options.__actions = options.actions.split(',');
options.__actions = options.__actions.map(_a => classify(_a));
If you know of a better way to process these please share. Thanks!
You need to pass the actions multiple times.
ng g my-collection:my-schematic --actions=GetById --actions=GetByFirstName
Define the parameter as an array within your schema.json file.
...
"actions": {
"type": "array",
"items": {
"type": "string"
},
"description": "The name of the actions."
},
...
Also in your schema.ts.
export interface Schema {
actions: string[]
}
If you want to pull them right off of the command args, you can do the following:
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "Sample",
"title": "Sample Schematic",
"type": "object",
"description": "Does stuff.",
"additionalProperties": false,
"properties": {
"things": {
"type": "array",
"items": {
"type": "string"
},
"$default": {
"$source": "argv"
},
"description": "Things from the command-line args."
}
}
}
Then when you run your schematic you can do:
schematics schematic-lib:sample stuff other-stuff more-stuff
In this case, the things property will be ['stuff', 'other-stuff', 'more-stuff'].
Edit: Note that the required value in the schema won't cause the schematic to fail if you don't provide any args. You'd need to do validation on that property in your schematic.

Generating GraphQL GUI from Schema and Schema from GUI

While using GraphiQL works well, my boss has asked me to implement a user interface where users can check elements presented to them via UI elements like checkbox, map relationships and get the data and doing this will generate a graphql input for the person, call the API and get the result back to the user.
So, basically this involves 2 generations. Generating a user interface from a GraphQL schema and generating a GraphQL input query from the user's selection.
I searched and I was not able to find any tools which already do this. My server is in Node and I am using Express GraphQL. I converted my express schema to GraphQLSchema language using https://github.com/graphql-cli/graphql-cli and I introspected the GraphQLSchema language using the introspect function at https://github.com/sheerun/graphqlviz/blob/master/cli.js
The object which I got was something like this (only partial schema output given below)
`
"data": {
"__schema": {
"queryType": {
"name": "Query"
},
"mutationType": {
"name": "Mutation"
},
"subscriptionType": null,
"types": [{
"kind": "OBJECT",
"name": "Query",
"description": null,
"fields": [{
"name": "employee",
"description": null,
"args": [{
"name": "ecode",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}],
`
I am looping through the elements trying to generate UI but I am quite stuck.
What is the best way to do this? Thanks in advance.
Well for the part of generating the ui from the introspection query, I think that the response contains enough data for a sufficient ui (description for each field can be used as a placeholder for each field's input box). If you're asking how can you generate a dynamic form from the introspection response, you can take a look at other projects that created transformers from json to html forms for inspiration/usage (take a look at https://github.com/brutusin/json-forms/blob/master/README.md#cdn). For complex fields (not primitive types) you may need to do some more work.
For the schema generation from the ui, you can use any query builder tool, and build a query according to the user inputs. Each combobox will be mapped to a specific SCHEMANAME.FIELDNAME and the value will be the value of the input box.
I hope it helped a bit. BTW, it sounds like an interesting tool so let us know if you succeed!

Resources