Situation:
I am opening a form via a SysInfoAction (SysInfoAction_FormrunQuery to be exact) from an error message (info log) as follow (Compressed a bit):
query.addDataSource(tableNum(WDPErrorLogView)).addRange(fieldNum(WDPErrorLogView, ErrorOutboundMessage)).value(SysQuery::value(resultRecId));
error("#WDP1299", '', SysInfoAction_FormrunQuery::newFormnameQuery(formStr(WDPErrorLog), query));
Problem:
The form I am calling here, has multiple tabs, since it can be opened with queries from various tables. I would like to capture this calling record to not only filter on the record passed (This already happens thanks to the SysInfoAction), but also make the appropriate tab page active.
I thought that element.args().record() would contain this calling record, but to my surprise it does not. Any ideas how to could get hold of this record... or, at least its table id?
This is easy. Just add a parmMethod for an object/caller to \Classes\SysInfoAction_FormrunQuery. Copy the static method newFormnameQuery and call it newFormnameQueryWithCaller for example and then add an extra argument, then set that argument in your parm method with the same style as newFormnameQuery.
Then in your \Classes\SysInfoAction_FormrunQuery\run, where it sets up the args record, just add args.caller(...) and set your caller object if it exists.
Related
In a certain scenario, I want to pass a field value(in string format) to the CouchDB and get associated doc (or only its id) which contains that particular string value in one its fields. In case, if no doc contains that particular field value, I would like CouchDB design functions to automatically create one and return the newly created doc.
I can accomplish this by making a GET request followed by a PUT request if there is no doc with that particular field value. Is there any way to get this done with just one POST request?
Design document functions (other than updates) cannot modify the data in any way.
So no, this is not possible.
You can write a list function to return you a new document if the results are empty, but it cannot save it automatically.
I have a list bound to model backed by a DS.RecordArray, as used the Ember data sample js fiddle. When I call this.store.find({id}) with a valid id, everything works as expected. However, when I call this.store.find({id}) with either a non-existing id or an empty string, an empty model is added to the DS.RecordArray, which is reflected in my bound list.
I've created an example of this behavior in a JSFiddle here. My example has two buttons to showcase two cases:
Calling find('post', 14) where 14 represents an id that does not exist. In this case, pressing this button once adds a blank element to the list and subsequent presses do nothing.
Calling find('post', '') where the empty string is passed instead of an id. In this case, every time this button is pressed, a blank element is added to the list.
Is this behavior expected? If so, what would be the best way to avoid these empty elements in my list?
store.find("type", id) will delegate to store.findById(type, id), which calls store.recordForId(type, id). If you check out the function body of recordForId(), you'll see that it checks the typeMap for the id, and if it doesn't exist, calls buildRecord(type, id), which creates a record of that type and adds it to the typeMap.
It's expected behavior in that it's clearly intended to do so, but whether it's a good idea or not can be argued.
It's not a good idea, for my application, so I override the store.findById to Ember.assert() on the id being truthy, since I'm never trying to find a record with 0, null, or undefined id's.
Good Morning,
why there are two methods, who returning the almost the same result.
I know "only", that the method Method.fetch() returns a promise.
What is the main difference between this two methods?
They return different results :) fetch returns a promise (as you said) immediately, which upon resolution will be your record. find returns a record immediately (possibly empty). If the record already exists client side then it will return that record, if it doesn't, it's an empty record, and once ember model finishes fetching the data it will populate the record with it's properties. They both have their pros/cons. fetch is safer for async programming if you depend on the record being populated before using it. find is convenient for immediate response time, with delayed population. Click run inside the examples a few times to view the differences.
Find
http://jsbin.com/UXOtOJI/20/edit
Fetch
http://jsbin.com/porozuno/1/edit
I would like to do something like:
App.Model.find({unique_attribute_a: 'foo'}).objectAt(0).get('attribute_b')`
basically first finding a model by its unique attribute that is NOT its ID, then getting another attribute of that model. (objectAt(0) is used because find by attribute returns a RecordArray.)
The problem is App.Model.find({unique_attribute_a: 'foo'}).objectAt(0) is always undefined. I don't know why.
Please see the problem in the jsbin.
It looks like you want to use a filter rather than a find (or in this case a findQuery). Example here: http://jsbin.com/iwiruw/438
App.Model.find({ unique_attribute_a: 'foo' }) converts the query to an ajax query string:
/model?unique_attribute_a=foo
Ember data expects your server to return a filtered response. Ember Data then loads this response into an ImmutableArray and makes no assumption about what you were trying to find, it just knows the server returned something that matched your query and groups that result into a non-changable array (you can still modify the record, just not the array).
App.Model.filtler on the other hand just filters the local store based on your filter function. It does have one "magical" side affect where it will do App.Model.find behind the scenes if there are no models in the store although I am not sure if this is intended.
Typically I avoid filters as it can have some performance issues with large data sets and ember data. A filter must materialize every record which can be slow if you have thousands of records
Someone on irc gave me this answer. Then I modified it to make it work completely. Basically I should have used filtered.
App.Office.filter( function(e){return e.get('unique_attribute_a') == 'foo'}).objectAt(0)
Then I can get the attribute like:
App.Office.filter( function(e){return e.get('unique_attribute_a') == 'foo'}).objectAt(0).get('attribute_b')
See the code in jsbin.
Does anyone know WHY filter works but find doesn't? They both return RecordArrays.
If I'm not mistaken, it seems that FinalBuilder 7's action list parameters only support input values. Is there any way I can simulate a workaround for return parameters? I do not want to store return parameters in a global temp variable or even a stack, because I'm calling the same action list multiple times asynchronously.
Here is sample of what I want to do. (Notice the shared use of the same action list)
Async Action Group
+-Action Group
| +-Run Action List - [Do Some Calculation]
| +-Replace variable A with return parameter from previous action list
+-Action Group
+-Run Action List - [Do Some Calculation]
+-Replace variable B with return parameter from previous action list
I'm currently using an INI file in the action list to save return values. The calling method passes a parameter to the action list specifying to which INI key to save to. The calling method then reads the value from the INI from the key.
Surely there has to be a more elegant way to do this?
I have never seen any way to return variables from action lists.
That would be an excellent suggestion to post in the FinalBuilder Wish List forum.
Many of requests in the past there are now features of the product.
I think it would require giving scope to variables to something like an Action Group to pull it off. But it would help some of my scripts as well. Update: I found that FB 7 supports Local Variables. But it still does not address the needs of this answer.