How to get value of 'select' type instead of labels on button submit in form io for default set value? - select

Successfully rendered form using form-io. And I have select fields with defaultValue as,
{
"authenticate": false,
"hidden": false,
"data": {
"values": [{
"label": "New",
"value": 1
}, {
"label": "In Progress",
"value": 2
}, {
"label": "Resolved",
"value": 3
}, {
"label": "Feedback",
"value": 4
}, {
"label": "Closed",
"value": 5
}, {
"label": "Rejected",
"value": 6
}]
},
"defaultValue": "New",
"multiple": false,
"labelMargin": 3,
"tableView": true,
"clearOnHide": true,
"labelWidth": 30,
"label": "Status",
"autofocus": false,
"type": "select",
"input": true,
"protected": false,
"labelPosition": "left-right",
"unique": false,
"persistent": true,
"key": "ticket_status",
"dataSrc": "values",
"validate": {
"required": true
}
}
and on button click I have to get those value. Now I am getting the labels for default set options, not value.On submit button click am doing as follows,
Formio.createForm(document.getElementById('formio'), data,{
readOnly: false
}).then(function(form) {
form.on('submit', function(event) {
that.savingNewTicket(event.data);
});
});
but when I select any other option the value is getting on submit but for defaultValue set option I am getting those labels not value. How can I get value??

Related

Create api not create a form for sample JSON for picture choice rest of all working fine

Create api not create a form for sample JSON for picture choice rest of all working fine
{
"ref": "nice_readable_picture_choice_reference",
"title": "Picture Choice Title",
"type": "picture_choice",
"properties": {
"description": "Cool description for the picture choice",
"randomize": true,
"allow_multiple_selection": false,
"allow_other_choice": true,
"supersized": false,
"show_labels": false,
"choices": [
{
"ref": "foo_choice_ref1",
"label": "Foo 1",
"attachment": {
"type": "image",
"href": "https://images.typeform.com/images/4bcd3"
}
},
{
"ref": "foo_choice_ref2",
"label": "Foo 2",
"attachment": {
"type": "image",
"href": "https://images.typeform.com/images/4bcd3"
}
}
]
},
"validations": {
"required": false
}
}

Cannot identify required and optional reviewers when getting policy configuration from Azure DevOps REST API

I query policy configurations over this API: https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations/get?view=azure-devops-rest-5.0
The policy does have required and optional reviewers groups set, but I cannot tell from the response the REST API returned:
{
"createdBy": {...},
"createdDate": "2018-11-30T04:35:02.2816989Z",
"isEnabled": true,
"isBlocking": true,
"isDeleted": false,
"settings": {
"requiredReviewerIds": "7ca7ce21-a99d-4873-aea7-ba4de2c6fc54",
"scope": ""
},
"_links": {
"self": "#{href=https://dev.azure.com/myAccount/11111111-2222-3333-4444-555555555555/_apis/policy/configurations/1953}",
"policyType": "#{href=https://dev.azure.com/myAccount/11111111-2222-3333-4444-555555555555/_apis/policy/types/fd2167ab-b0be-447a-8ec8-39368250530e}"
},
"revision": 1,
"id": 1953,
"url": "https://dev.azure.com/myAccount/11111111-2222-3333-4444-555555555555/_apis/policy/configurations/1953",
"type": {
"id": "fd2167ab-b0be-447a-8ec8-39368250530e",
"url": "https://dev.azure.com/myAccount/11111111-2222-3333-4444-555555555555/_apis/policy/types/fd2167ab-b0be-447a-8ec8-39368250530e",
"displayName": "Required reviewers"
}
},
{
"createdBy": {...},
"createdDate": "2019-01-18T09:38:32.9506909Z",
"isEnabled": true,
"isBlocking": false,
"isDeleted": false,
"settings": {
"requiredReviewerIds": "0bd7df6e-9f54-408a-bccf-25ace8912acf",
"scope": ""
},
"_links": {
"self": "#{href=https://dev.azure.com/myAccount/11111111-2222-3333-4444-555555555555/_apis/policy/configurations/2101}",
"policyType": "#{href=https://dev.azure.com/myAccount/11111111-2222-3333-4444-555555555555/_apis/policy/types/fd2167ab-b0be-447a-8ec8-39368250530e}"
},
"revision": 1,
"id": 2101,
"url": "https://dev.azure.com/myAccount/11111111-2222-3333-4444-555555555555/_apis/policy/configurations/2101",
"type": {
"id": "fd2167ab-b0be-447a-8ec8-39368250530e",
"url": "https://dev.azure.com/myAccount/11111111-2222-3333-4444-555555555555/_apis/policy/types/fd2167ab-b0be-447a-8ec8-39368250530e",
"displayName": "Required reviewers"
}
}
What did I miss?
isBlocking is the flag that determines whether a policy is optional or not.

Populate picklist dynamically based on filepath type in Azure Devops?

In Azure Devops, I am building one extension with build task where input picklist field is dependent on the another input filepath field.
When the user provides an input filepath, I wanted to dynamically read and populate the picklist with new items.
I tried to search and implement but couldn't find a way.
Any help or guidance will be appreciated. I found the below example to help me out for static values.
{
"name": "action",
"type": "pickList",
"label": "Action",
"defaultValue": "Publish",
"required": true,
"helpMarkDown": "Select the Action to perform",
"options": {
"Publish": "Publish Changes",
"Script": "Script Changes",
"DeployReport": "Generate Deployment Report"
}
}
The out-of-box tasks are open source, so you can take a look through the repository to get some ideas of the patterns they use. Here is an example from the Download Build Artifacts task. The build definition is dependent on the project that is defined.
{
"name": "project",
"type": "pickList",
"label": "Project",
"defaultValue": "",
"required": true,
"visibleRule": "buildType == specific",
"properties": {
"EditableOptions": "True",
"DisableManageLink": "True"
},
"helpMarkDown": "The project from which to download the build artifacts"
},
{
"name": "definition",
"aliases": [
"pipeline"
],
"type": "pickList",
"label": "Build pipeline",
"defaultValue": "",
"required": true,
"visibleRule": "buildType == specific",
"properties": {
"EditableOptions": "True",
"DisableManageLink": "True",
"IsSearchable": "True"
},
"helpMarkDown": "Select the build pipeline name"
},
Then in the dataSourceBindings section believe it uses the target from the previous selection as a parameter input.
"dataSourceBindings": [
{
"endpointId": "tfs:teamfoundation",
"target": "project",
"endpointUrl": "{{endpoint.url}}/_apis/projects?$skip={{skip}}&$top=1000",
"resultSelector": "jsonpath:$.value[?(#.state=='wellFormed')]",
"resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{name}}}\" }",
"callbackContextTemplate": "{\"skip\": \"{{add skip 1000}}\"}",
"callbackRequiredTemplate": "{{isEqualNumber result.count 1000}}",
"initialContextTemplate": "{\"skip\": \"0\"}"
},
{
"endpointId": "tfs:teamfoundation",
"target": "definition",
"endpointUrl": "{{endpoint.url}}/{{project}}/_apis/build/definitions?api-version=3.0-preview&$top=500&continuationToken={{{continuationToken}}}&name=*{{name}}*&queryOrder=2",
"resultSelector": "jsonpath:$.value[?(#.quality=='definition')]",
"parameters": {
"project": "$(project)",
"name": "$(name)"
},
"resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{name}}}\" }",
"callbackContextTemplate": "{\"continuationToken\" : \"{{{headers.x-ms-continuationtoken}}}\"}",
"callbackRequiredTemplate": "{{{#headers.x-ms-continuationtoken}}}true{{{/headers.x-ms-continuationtoken}}}",
"initialContextTemplate": "{\"continuationToken\" : \"{{{system.utcNow}}}\"}"
},

VSTS: Feed package version variable as dropdown when performing a release

When we perform a release, we need to select specific package versions to deploy (latest by default, but it could be older versions as well). Right now that field is a simple text box where we have to manually specify the version, but this is error prone since the user can basically put whatever they want there and requires us to update the release definition whenever a new version is pushed to the feed. Is there some way to configure the variable in the definition to look at the specific versions of a package in a feed and display that as a dropdown to the user?
There isn't any way to do this by default. You need to create a custom build task and call the Feed API to achieve that.
For example, add following section in your custom build task:
"inputs": [
{
"name": "feedList",
"type": "pickList",
"label": "feedList",
"defaultValue": "",
"required": false,
"helpMarkDown": "Select the feed.",
"properties": {
"DisableManageLink": "True"
}
},
{
"name": "packageList",
"type": "pickList",
"label": "packageList",
"defaultValue": "",
"required": false,
"helpMarkDown": "Select the package.",
"properties": {
"DisableManageLink": "True"
}
},
{
"name": "versionList",
"type": "pickList",
"label": "versionList",
"defaultValue": "",
"required": false,
"helpMarkDown": "Select the version.",
"properties": {
"DisableManageLink": "True"
}
}
],
"dataSourceBindings": [
{
"target": "feedList",
"endpointId": "tfs:feed",
"endpointUrl": "{{endpoint.url}}/_apis/packaging/feeds",
"resultSelector": "jsonpath:$.value[*]",
"resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{name}}}\" }"
},
{
"target": "packageList",
"endpointId": "tfs:feed",
"parameters": {
"feed": "$(feedList)"
},
"endpointUrl": "{{endpoint.url}}/_apis/packaging/feeds/{{{feed}}}/Packages",
"resultSelector": "jsonpath:$.value[*]",
"resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{name}}}\" }"
},
{
"target": "versionList",
"endpointId": "tfs:feed",
"parameters": {
"feed": "$(feedList)",
"package": "$(packageList)"
},
"endpointUrl": "{{endpoint.url}}/_apis/packaging/feeds/{{{feed}}}/Packages/{{{package}}}/Versions",
"resultSelector": "jsonpath:$.value[*]",
"resultTemplate": "{ \"Value\" : \"{{{version}}}\", \"DisplayValue\" : \"{{{version}}}\" }"
}
],
You will get a list to select the package version:
And then you can get the selected version and set the variable value to the selected one in the customer build task.

elasticsearch sort index on #timestamp not working

I cannot see why it's not working. I'm trying to sort my index by sort.field: "#timestamp" and it's saying "unknown index sort field:[#timestamp].
I've also tried using "timestamp" and another field which is as type "date" but still no success. Using field type "ip" gives still the same error.
here the error message:
[2018-06-05T01:45:32,102][WARN ][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"xxx-logstash-2018.06.05", :_type=>"doc", :_routing=>nil}, #<LogStash::Event:0x43ff9351>], :response=>{"index"=>{"_index"=>"xxx-logstash-2018.06.05", "_type"=>"doc", "_id"=>nil, "status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"unknown index sort field:[#timestamp]"}}}}
here the field mapping:
"properties": {
"#timestamp": {
"type": "date",
"format": "dateOptionalTime"
},
"log_date": {
"type": "date"
},
"#version": {
"type": "keyword"
},
"geoip": {
"dynamic": true,
"properties": {
"ip": {
"type": "ip"
},
"location": {
"type": "geo_point"
},
"latitude": {
"type": "half_float"
},
"longitude": {
"type": "half_float"
}
}
}
}
here the index template settings:
"settings": {
"index": {
"codec": "best_compression",
"refresh_interval": "30s",
"sort": {
"field": "#timestamp",
"order": "desc"
},
"store": {
"type": "niofs"
},
"number_of_shards": "3",
"number_of_replicas": "1"
}
},

Resources