Is it possible using NSArrayController to bind a NSTextField's value to a particular item in the array? In particular, I want to bind to a property on the first item in the array, and show nothing if the array is empty.
Using arrangedObjects.command shows just "(" -- presumably it's trying to show a multi-line string with comma-separated strings for each item. I just want the first one.
Bind the text field to selection.command, and programmatically set the array controller's selection index to 0. You may need to also re-set the selection index to 0 any time you add or remove items to the content array.
Obviously, this won't work if you're allowing the user to select items within the array controller (you'd need a second array controller). I'm assuming that's not the case, since if it were, I'd expect you to want to show the user-selected object, instead of always the first object.
EDIT: Better yet, do nothing like this—if the object that is first in the array has some special status, you should make a separate non-array property (in the same object that holds the original array, from which I assume the array controller is getting it) to hold the object that has that status.
Related
I have an action in a Power Automate flow that returns an array of objects. In my case, the response will only contain a single item in the array. I'd like to work with that single item downstream in the flow, but I want to avoid the "Apply To Each" loop that is automatically inserted when I reference any property of the array item.
I know I can use a Compose action with the first() expression to get the first item in the array. But doing so hurts usability because the dynamic content window only shows the Outputs of the Compose action (i.e., I lose the ease of referencing individual properties of the item in the dynamic content window).
I know I can reference those properties via an expression, but is there a way to get a strongly typed reference to a single array item without incurring an unnecessary Apply to Each?
You can try Parse JSON, this will give you Dynamic content reference once you set it through first expression.
Parse JSON image
As an Content input use first(variables('Array')) then generate Schema from the sample, the sample must be a single item like this:
{
"ID": "11111-2222-333-4444-555",
"Column1": "lorem ipsum",
"Column2": "lorem ipsum 2"
}
Parse JSON reference
Is there a way to retrieve the values inside the 'appSettings' section of my web.config file as a collection of name-value pairs? I want to create an api controller method that returns this object so that I can access the collection of settings from my front-end(as a JSON object ideally). I tried returning WebConfigurationManager.AppSettings but it only returns an array of string containing only the name of the settings (without the value). I had been searching for an answer for almost 2 hours but couldn't find one. Any help? Thanks.
There is no simple mechanism provided for this that I am aware of, for the reason that the NameValueCollection type is more than a simple Name/Value dictionary and might not always be easily represented as one.
Each key in a NameValueCollection may have more than one value.
When more than one value is assigned to a particular Name then the Value of that Name becomes a comma separated list of all of those values. If any one of those values itself contains a comma then this can make deciphering such values difficult (i.e. application/context specific).
As a result, you have to decide how you need to handle the contents of a specific NameValueCollection in each case.
If your particular AppSettings consist of truly simple name/value pairs or you are happy to deal with any comma separated multi-values then you can of course do something similar to:
var dict = new System.Collections.Generic.Dictionary<String, String>();
var settings = System.Configuration.ConfigurationManager.AppSettings;
foreach ( var k in settings.AllKeys )
{
dict.Add(k, settings[k]);
}
var json = Newtonsoft.Json.JsonConvert.SerializeObject(dict);
Hopefully that will set you down the right track if not provide a complete solution.
I want to populate my select box from the Laravel IoC Container.
App\Http\Utilities\BillingHelper.php
views/billing/create.blade.php
views/billing/edit.blade.php
Create the table:
Now, instead of the value, i want to display some flags and currency symbols.
Should i use mutators?
Problem
If i use mutators, when i open the edit page, i see always the first value selected, from the BillingHelper, instead of the choosen one.
Any help? Thanks.
I know it should be a comment, but I have no reputation.
What if, on you edit page, you replace null on Form::select with $client->language and $client->currency.
I know that you area binding the values with Form::Model. But worth a try.
When you use mutators the matching won't occur anymore. You'll have to use a matching static array according to the values you'll return. (the flags)
You can make it work if you make a mutator for saving the data also and simplify again to the ['it', 'en', 'lv'], otherwise your saved data will differ and the initial mutator won't work the second time. You can still make a one-time-only test.
This is why:
Your form binding is using $bill->language to retrieve the actual stored data, and compare it with the values in your $bill::lang static array. If no match found, than the first value will be always selected.
Can you provide the the currency and language fields definition in the migration for the bill?
Also retrive your values from your bills DB and paste them here for language and currency. They must be in the defined static sets.
Laravel has a way of skipping the accessor/mutator by using
$model->getOriginal('data_field').
The "getOriginal()" gets the model's original attribute values.
I have 2 entities, let's call them Parent and Child, with a 1:n relationship, where one Parent can have 0-n Child.
The Parent has two fields, Parent.Number and Parent.Name. When creating the Child via the plus button in a subgrid of Parent, the Child.Name should be preset to:
Child of Parent.Name (Parent.Number)
I've tried lots of different approaches wich all led to dead Ends. Some of them were:
Calculating via BusinessRules
Calculated Field on Child in combination with BusinessRules
Calculated Field on Parent, transferring the precalculated Text to the Child entity by Mapping.
Calculated Field on Parent, using a BusinessRule to set it's value as the default value of Child.Name
Using a workflow for Child.OnAfterCreate (works, need it in the OnFormLoad, though)
(For brevity I will not go into details of why each approach did not work, but will elaborate on request.)
Is there any way to achieve this without the use of Client side Scripting that I am not aware of?
Without using JavaScript (which is a solution) I can only suggest the following approaches (of which you can use some or all) which are all compromises really:
Change your requirement to make the name as shown below. A business rule on the child can then be used to populate this information. It can access the name but not any other field, i.e. number.
Child of Parent.Name
Use a quick view form to show the parent details on the child. This allows users to see the data even if the name is not set correctly.
Use one of the above, and the workflow. So the correct value is still finally set and you provide the user with as much information as possible until that point.
Remove the name field from the child form body. Use a workflow to set the value, when the form is saved. CRM displays names at the top of the form so it will appear as soon as they save but they wont see an empty field before that.
Change the name of the parent record to as shown below, you can then use that in business rules on the child.
Parent.Name (Parent.Number)
I am trying to assign a value to an item within the serialized object variable. How do I go about that? I have pasted below an excerpt of what the SESSION array looks like as key/value.
selected_region=18
delivery_region=18
cart=O:9:"cart":40:{s:16:"delivery_country";s:2:"US";s:16:"selected_country";s:2:"US";s:15:"delivery_region";s:2:"18";s:15:"selected_region";s:2:"18";s:24:"selected_shipping_method";s:9:"tablerate";s:24:"selected_shipping_option";s:10:"Table Rate";s:24:"selected_shipping_amount";d:8;s:6:"coupon";N;s:14:"tax_percentage";s:1:"0";s:9:"unique_id";s:40:"cdaa5a32e39b5470f21f43dd847e8cb1eb3d9327";s:6:"errors";a:0:{}s:9:"total_tax";i:0;s:13:"base_shipping";N;s:19:"total_item_shipping";N;s:14:"total_shipping";N;s:8:"subtotal";i:0;s:11:"total_price";N;s:13:"uses_shipping";N;s:13:"is_incomplete";b:1;s:10:"cart_items";a:0:{}s:9:"cart_item";O:14:"cart_item":34:
I am trying to assign say "selected_shipping_amount" to another value. How can I reach into that and assign it?
Thanks...
I think your only option is to unserialize it, assign the value and then serialize it again.