How to apply an NSPredicate to a custom XLForm row? - xlform

I have a row of type XLFormRowDescriptionTypeSelectorPush
I set row.value to a custom class Agreement and row.addValidator(AgreementValidator())
I want another to be hidden/shown depending upon the value of Agreement.agree (which is "Accepted" or "Declined").
I can't figure out how to do this. Here's where I am so far:
other_row.hidden = NSPredicate(format:"$other_tag.value != "Accepted")
But the value of the other_tag row is Agreement and not a string. How can I compare with Agreement.agree?

Try this.
other_row.hidden = NSPredicate(format: "NOT $other_tag.value.agree != 'Accepted'")

Related

I have a query that returns '[ ]'. I want it to be shown on a widget as not having any value, how do I do this?

I have a query in my flutter app that should return empty if 'archived' 'isNull' is set to true. I accomplished that, but the issue I'm having now is the fact that the query returns empty (i.e [ ]). And on the widget, I want this to be shown as not having any value but instead, an empty pair of brackets '()' keep showing up.
I have tried checking for when query data equals null, something like this:
if (queryResult.data == null){
// The idea is for it not to just return '()' as the value
value = null;
}
else{
value = queryResult.data;
}
And also:
if (queryResult.data == []){
value = null;
}
else{
value = queryResult.data;
}
How do I go about this? Thanks in advance.
If "data" is a list why not try data.isEmpty() ? And also if you only need to avoid the brackets (dirty fix alert ⚠️) whatever you did it's returning a string value '()' then you check that
if(yourResults == '()' )value == null;
And please add more details for a better answer .

Crystal Report-FORMULA

I am trying to create two FORMULA fields in Crystal Reports with the same Column in the Database using the following Syntax:
FORMULA1- COLL_DATE
if Collection_Rejection_Desc = 'Cleared'
then Coll_Rej_Dt
else null
FORMULA2- REJ_DATE
if Collection_Rejection_Desc = 'Rejected'
then Coll_Rej_Dt
else null
But it is giving me error saying "a Date and Time Field is expected here"
How can I resolve this?
you can't give one value as date time and other as null in a if condition.. change like this:
FORMULA1- COLL_DATE
if Collection_Rejection_Desc = 'Cleared'
then ToText(Coll_Rej_Dt)
else ""
FORMULA2- REJ_DATE
if Collection_Rejection_Desc = 'Rejected'
then ToText(Coll_Rej_Dt )
else ""
You may want to return Coll_Rej_Dt when the condition is correct, otherwise return null.
you can use Switch by replace if condition. Because in if condition, you need to return same data type in true part and false part.
So, try this...
Switch (Collection_Rejection_Desc = 'Cleared', Coll_Rej_Dt)
Switch (Collection_Rejection_Desc = 'Rejected', Coll_Rej_Dt)
this will return value when the condition is true.

How to find button with predicate under UITests in Xcode7?

I need to access following button:
This line works fine:
app.buttons["Reorder 1, $27 000, LondonStreet, ok, Pending"]
but this don't:
app.buttons.elementMatchingPredicate(NSPredicate(format: "accessibilityTitle BEGINSWITH[cd] %#", "Reorder 1"))
When finding elements via predicates you must use the XCUIElementAttributes Protocol. For this example, I don't think title will actually work, but try using label (which should map to accessibilityLabel).
For some reason the %# format option doesn't seem to work in Swift. Also note the extra single quotes around "Reorder 1".
let predicate = NSPredicate(format: "label BEGINSWITH[cd] 'Reorder 1'")
let button = app.buttons.elementMatchingPredicate(predicate)

Dijit/Dojo Inline - Filtering Select - DataStore

I am using an inline filteringselect with datastore, as follows:
I am using ABBR as the identifier and NAME as the value.
The filtering selects and works correctly, but I have two issues.
Firstly, how do I retrieve the ABBR for the selected option NAME?
I have tried various things, including .innerHTML but that only retrieves the selected item name, not the identifier.
Secondly, when using the datastore option, how can I choose the default selected item, for example if it was a scale of 1 to 10 and I wanted 5 as the default selection, how can I do this?
Any ideas and advice would be greatly appreciated.
Mank thanks
dojo.addOnLoad(function() {
// inline store
str = new dojo.data.ItemFileReadStore({data: storeData10})
var itmes;
// for storing the store's items
str.fetch({
onComplete:function(itms){
itmes= itms;
console.log(itms)
}
})
dijit.byId("cmbx1").store = str
dojo.connect(dijit.byId("cmbx1"), 'onChange',function(){
//console.log(arguments);
//get the value u c in screen
var whatvseeinselect = dijit.byId("cmbx1").focusNode.value;
dojo.forEach(itmes, function(itm){
//compare the value u c in screen with store itms. once matched take that item and get the name attr or other attr if u require..
if(whatvseeinselect == str.getValue(itm,"name")){
console.log(str.getValue(itm,"name"));
}
})
})
});
I'm not sure whether this is the correct way.
Hope this helps

Core Data Predicates with Subclassed NSManagedObjects

I have an AUDIO class. This audio has a SOUND_A subclass and a SOUND_B subclass. This is all done correctly and is working fine.
I have another model, lets call it PLAYLIST_JOIN, and this can contain (in the real world) SOUND_A's and SOUND_B's, so we give it a relationship of AUDIO and PLAYLIST.
This all works in the app.
The problem I am having now is querying the PLAYLIST_JOIN table with an NSPredicate. What I want to do is find an exact PLAYLIST_JOIN item by giving it 2 keys in the predicate
sound_a._sound_a_id = %# && playlist.playlist_id = %#
and
sound_b.sound_b_id = %# && playlist.playlist_id = %#
The main problem is that because the table does not store sound_a and sound_b, but stored audio, I cannot use this syntax. I do not have the option of reorganizing the sound_a and sound_b to use the same _id attribute name, so how do I do this?
Can I pass a method to the predicate? something like this:
[audio getID] = %# && playlist_id = %#
It gets a little complicated but you need to add a third condition to the predicate:
(entity.name = sound_a && _sound_a_id = %# && playlist.playlist_id = %#) && (entity.name = sound_b && sound_b_id = %# && playlist.playlist_id = %#)
This is assuming you are querying against the audio abstract and telling it to return subclasses. Because the condition is checked left to right, if the first condition fails it will move on and not throw errors because _sound_a_id does not exist.
The first condition is referencing the NSEntityDescription that is a part of the NSManagedObject and its name attribute is just a string.