Clearing only values from an object on click of a function by keeping the keys in polymer 3 - polymer-3.x

I am getting the keys of an object from an API response like this
"subscriptionDetails":
[
{
"subscriptionKey":"Mobile Number",
"dataType":"NUMERIC",
"isMandatory":"M",
"length":8
}
]
keys can be more than one. I have entered some value for mobile number. On click of a button i want to clear the value which i have entered by keeping the keys. I tried few things like below but none worked. Kindly help.
this.set("subscriptionDetails.subscriptionValue", undefined);
this.set("subscriptionValue", undefined);

Your object contains an array in which objects are stored, hence the [ and the {.
Therefor subscriptionDetails.subscriptionValue wont work since you need to reference the array first like:
subscriptionDetails[0].subscriptionValue
Furthermore your data contains no 'subscriptionValue' but seems to contain a 'subscriptionKey'

Related

Polymer Firebase Binding for Location

I've been trying to bind a location value to a "note" (as in the na-notes example in codelabs) via firebase. I'm using the paper-input-place, but have tried with several other elements to no avail. So far, this is what I have (corresponding to the na-note.html document):
<paper-input-place is="iron-input" bind-value="{{address}}" value="{{address}}" label="Address" api-key="key">
And then I have this on my na-editor.html:
<na-note id="note" title="{{note.title}}" location="{{note.place_id}}" price="{{note.price}}" rooms="{{note.rooms}}" beds="{{note.beds}}" baths="{{note.baths}}" editable></na-note>
I am thinking that it probably is a silly mistake, but I've been going at it for two days and I'm starting to loose my patience, so any help would be appreciated!
Thanks!
at above na-note element, note is an object retrieved from firebase. so, to this path, you will need to save location data of the note. So, when you received the proper data from paper-input-place element, you will need to save it to the note's path as a location. So, first retrive the address:
<paper-input-place hide-error place="{{place}}" api-key="[[apiKey]]" on-place-changed="searchPlaceChanged" > </paper-input-place>
...
searchPlaceChanged(p){
console.log(p.detail.value); // You will need to see the place data, which you may like to save only some detail like: p.detail.value.formatted_address;
this.set('note.place', p.detail.value.formatted_address);
}
Asuming just abobe note object (at set operation) is firebase-document's two way binding retrived data that you just editing.

Access the value of the array from the text in Watson

I have list of values defined in the values of array inside the text element.
Now, when the value of the aray is "Counting finished" I would like to route the flow to new node and pass some text to the user. How to achive the condition?
As that is output text the conversation tree can't see it unless you put it into the input or a context variable, and send it back into the tree.
The easier option is to create a counter. There is more details and an example conversation file here:
https://sodoherty.com/2016/09/22/using-counters-in-conversation/
Summary:
You create a context variable like countdown for example, and set it with a value to countdown from.
Then in your input text you can add the following code to initiate a decrement.
<? context.countdown-- ?>
This will be outputted though, so you can use a continue from to jump to another node which has append set to false. This will erase the counter from being displayed.
Optionally you can set the context variable directly like as follows.
{
"output": {
"text": "Decrementing countdown counter"
},
"context": {
"countdown": "<? context.countdown-- ?>"
}
}
This had issues in earlier versions of conversation though. I believe it should work now without issue.

Firebase database: Cannot loop through .push()'ed array

After pushing some objects to my Firebase sync database, and retrieving them, I get the following array:
(index) products time
-KNOR5bBgf1ilVehk7BI Array[1] "22:26:47"
-KNORdccyvXat8wsP0SF Array[2] "22:29:10"
When using Firebase's .push(), Firebase generates a random ID such as the one above.
After trying to loop them with Aurelia (using repeat.for)
<order-details repeat.for="order of bill.orders" order.bind="order"></order>
I get the following error
aurelia-task-queue.js:40 Uncaught TypeError: Cannot read property 'getCollectionObserver' of null_observeCollection # repeat.js:152itemsChanged # repeat.js:99selfSubscriber # aurelia-templating.js:3122call # aurelia-templating.js:2989flushMicroTaskQueue # aurelia-task-queue.js:117(anonymous function) # aurelia-task-queue.js:61
I am pretty sure it has to do with the keys (indexes), because before I used an incremental index (0, 1, 2, 3, ...) and it worked perfectly fine.
EDIT: I have experimented with other keys such as "0" and 2 and they don't work either. Seems Aurelia only knows how to repeat through arrays that start with 0???
Why is this happening?
You're trying to use repeat.for to loop over an object instead of an array. You'll need to convert it to an array to repeat over the properties of the object. See this article: http://ilikekillnerds.com/2015/08/iterating-objects-using-repeat-for-in-aurelia/
When you changed them to 0,1,2 javascript reads it as:
orders[0]
orders[1]
Javascript sees that as an array.
What you have is this:
orders['-KNOR5bBgf1ilVehk7BI']
orders['-KNORdccyvXat8wsP0SF']
Javascript sees this as an object. You can't loop over an object's properties without a value-converter using Aurelia's repeat.for.
Since it has to pass through a value-converter you may need to setup a binding singler to tell the repeat.for to update. You can find a simple example of that here: Update Aurelia observed property on change to containing array

Biztalk Preload output message before Map transform

I have 2 correlated incoming messages from 2 different systems (SystemA and SystemB) and I just want to basically copy over a couple fields from the SystemA message to the SystemBmessage.
So my Construct Message shape looks like this:
The Message Assignment shape just has this code inside it:
xmlIncomingNoAttachHolder = new System.Xml.XmlDocument();
xmlIncomingNoAttachHolder = msgMultiPartInNoAttachment.BodySegments;
// assigning the SsytemB version (no attachment) first.
// Also, since we are only copying a couple fields, this can serve as the base.
msgComboWithAttach = xmlIncomingNoAttachHolder;
msgComboWithAttach(XMLNORM.TargetCharset) = "UTF-8";
The map then just has the 2 input (SystemA schema and SystemB schema) ORU messages on left and the output ORU message on the right, which also shares the same schema as the SystemB input message.
My hope was that I could just use the message assignment code above to assign the Output msgComboWithAttach message, then use the mapper to map over the few fields that we need from the SystemA message to the SystemB message.
But it seems that as soon as I apply the map, it clears the pre-loaded msgComboWithAttach message before performing the transform and then applies the map. The resulting message then contains ONLY those fields that are copied over in the map and none of the other segments/fields that were assigned in the message assignment pre-load.
Is this expected behaviour, in which case, I would have to do a Mass-Copy on all the segments in the Map? Or is there a way to pre-load/copy the message like I want and then only Map a couple fields over?
Yes, that is the expected behavior since the transform will create a new message. You cannot use Xslt to modify a document in that way.
Dijkgraaf's solution will work. As an alternative, you can use the Orchestration xpath() function to read and set specific values in Message. See: http://msdn.microsoft.com/en-us/library/ee268159(v=bts.10).aspx
Yes, that is expected behaviour.
What you want to do is
Distinguish the fields in the schema(s) (target and source, in your case they may be the same one if I understand what you are saying).
Have the map first making sure that your map creates the fields you want to populate with some dummy values.
Have an assignment shape after that just has one line for each of the fields in the format msgDestination.record.field = msgSource.record.field; (Note: you might have multiple levels of records).
This works only for non-reoccurring fields. For reoccurring fields you need to use a multi-part map instead.

APIGEE querying data that DOESN'T match condition

I need to fetch from BaaS data store all records that doesn't match condition
I use query string like:
https://api.usergrid.com/<org>/<app>/<collection>?ql=location within 10 of 30.494697,50.463509 and Partnership eq 'Reject'
that works right (i don't url encode string after ql).
But any attempt to put "not" in this query cause "The query cannot be parsed".
Also i try to use <>, !=, NE, and some variation of "not"
How to configure query to fetch all records in the range but Partnership NOT Equal 'Reject' ?
Not operations are supported, but are not performant because it requires a full scan. When coupled with a geolocation call, it could be quite slow. We are working on improving this in the Usergrid core.
Having said that, in general, it is much better to inverse the call if possible. For example, instead of adding the property when the case is true, always write the property to every new entity (even when false), then edit the property when the case is true.
Instead of doing this:
POST
{
'name':'fred'
}
PUT
{
'name':'fred'
'had_cactus_cooler':true
}
Do this:
POST
{
'name':'fred'
'had_cactus_cooler':'no'
}
PUT
{
'name':'fred'
'had_cactus_cooler':'yes'
}
In general, try to put your data in the way you want to get it out. Since you know upfront that you want to query on whether this property exists, simply add it, but with a negative value. The update it when the condition becomes true.
You should be able to use this syntax:
https://api.usergrid.com/<org>/<app>/<collection>?ql=location within 10 of 30.494697,50.463509 and not Partnership eq 'Reject'
Notice that the not operator comes before the expression (as indicated in the docs).

Resources