Kentico 12: change value of one page type field based on value of another field - drop-down-menu

I have a custom page type with two fields, StateName and StateCode. I would like it so that when a value is selected in either of these fields, the other field’s value changes to match.
So for example, if I select “Alabama” in the StateName field, the value of the StateCode field would automatically change to “AL.” Or if I select “CO” in the StateCode field, the StateName field would automatically change to “Colorado,” etc. Is this possible?
(I have to keep these as two separate fields, because I need to display either the state name or the state code on the front-end depending on context. Therefore, I can’t use a single field with options like AL;Alabama because then the field only returns the value AL and I have no way of getting the display name Alabama).
I know Kentico has options for setting “dependent” fields, but that only appears to determine visibility – e.g. only display Field B if I select a particular value in Field A. I can’t find a way to actually change the selected value in one field based on the selected value in another field.

Two control solution seems some kind of an overkill here. You can use StateInfoProvider to get what you want.
StateInfo state = StateInfoProvider.GetStateInfo("Alabama")
The other way would be to use a simple drop down control and use
query like that :
select stateCode + '|'+ StateDisplayName, StateDisplayName from cms_State
to get get code and display name as value separated by |

Related

how to specify custom validation for user details like telephone number, last name etc. in Oracle Identity Manager?

I had logged in as xelsysadm in oracle identity manager and created different users, then i tried to create custom validation for fields such as telephone number and last name, but i don't know where to specify the regular expression and in what way the regular expression is to be specified. I had activated the sandbox,customized it and from the options i chose structure(located at the top left corner) and selected the telephone number column which is to be custom validated, then chose the corresponding tag for the telephone number column from right-side, then various display options were displayed such as VALUE, PARTIAL TRIGGERS etc, but i don't know where to specify the regular expression for validation and in what way it is to be mentioned.
I specified the below tag in VALUE field, but the result was not the expected.
af:validateRegExp pattern="/^+(\d+\s?)+$/"
Where to specify and how to specify the regular expression?
I specified af:validateRegExp pattern="/^+(\d+\s?)+$/" in the value field but it is not working as expected.
af:validateRegExp pattern="/^+(\d+\s?)+$/"
I expect the result to be like, when in future on creating a new user there should be strict validation for telephone number field like there must be a '+' sign in the beginning followed by numerical digits.

Change a field property in SNOW

I'm trying to change a field's default property in SNOW. Here in incidents we've a field Assigned to and it accepts some default values. But instead of that I want it to accept any values (Integer, String, Special characters etc). In my SNOW Form lay out tried the below.
Created a new String field, Named it as Assigned to Label and name as assigned_to and saved it and it ended up as shown below.
and when I added some random text in this field, it gave me the below error.
please let me know on how can I change this field to accept any string as Input.
Thanks
You are referencing the sys_user table on the form field Assigned to. You need to provide the value for the Assigned to field the sys_id from the User record.
Providing it with any text will result in an invalid reference since it is looking for the unique sys_id on the user table.

Can i make a field editable for a specefic role "System Administrator" if the field type is calculated in the form

I am using a calculated field in a form (Data Type = Single Line of Text), however I would like to make this field editable for a specific users having "System Administrator" roles.
I tried using the field security profile to make this field editable (so that System Admin can update or create records here) however update/create options are disabled here in security profile and cannot be altered.
Is there an appropriate way to achieve this? Can we make a calculated field editable for specific set of roles?
No, you cannot directly edit the value of a calculated field.
A work-around would be to create a separate field, where only specific users can enter data. In your calculated field you could then add a condition to take either the manually entered value from the other field (if it exists) and otherwise use the original action for the calculated field.
The calculated field is calculated in SQL when you retrieve it, but is not stored in field.
So, for a calculated field there IS NOT a place to store a value. This makes it impossible to have the same field be calculated in some cases and manual in other cases.
You would need to have two fields the calculated fields and an override field. In the calculated field you set a condition that if the override field contains data the action is to set the calculated field equal to the override field. The else has an action to calculate the field as your normally.
Here is an example where I created a field testca(`new_testca') that will if the Account Number is populated use that value and if not its value will be some text I entered, "NEED ACCOUNT NUMBER".

GWT (smartgwt) grid sort selected records top

I have a grid where the user can select records via checkbox in front of every record. Now I have a requirement to sort the records based on their selection, so that all selected records should be placed top, followed by the not selected ones.
Is there any standard function to achieve this? As an alternative I thought of saving the selection state as an attribute on every record and sort based on the attribute.
The code for the column is:
gridRealmDt.setSelectionType(SelectionStyle.SIMPLE);
gridRealmDt.setSelectionAppearance(SelectionAppearance.CHECKBOX);
I try to describe the code I use as the affected code is deeply nested in our own framework classes.
gridRealmDt is a subclass of smartgwt ListGrid. In my Dialog a create an instance of the grid which creates an instance of a database bound datasource. When the dialog is loaded the records are fetched from the database and after that a registered an dataArrivedHandler where I select the records which match records from another table.
I tried to place the selection attribute in an extra field and use that for sortig before my other sort criteria, but this does not work. Here is the code for the field I am using.
ListGridField txtSelected = new ListGridField(SELECTED, "");
txtSelected.setHidden(true);
txtSelected.setSortByDisplayField(true);
txtSelected.setCanSortClientOnly(true);
When I do not set the canSortClientOnly property the order by is sent to my database resulting in an error, as the table does not contain that field, so I set the property. Now I get following error
Removing field from the sort Specifier array because it specifies canSort Client Only: true and all data is not yet client-side.
I also tried to use a sortNormilizer on the Name field which is my main sort criteria, but the normalizer is called before the selection value is set to the record.
record.setAttribute(CARealmDS.SELECTED,selected ? "a" : "b");
I also cannnot find a way to call the normalizer when selection changes.
Currently we are using Smart GWT Version 6.0p.
I don't think there is any standard function. Just use grid store update. Place checked items first.

MS Access table list order is defaulted in subform

I have a subform with a table, where some fields are restricted to tables. The tables are sorted in the correct order, but when it is used in the subform, it is set to default sorting. I can't find the location of the correct place to set the sorting criteria. I tried using query instead of a table, but i could only sort either by ascending or descending (or nothing). All three options resultet in undesired order. Example of the phase being sorted as default despite the table settings:
Suggestions?
As Gustav suggests, add another field to your t_Phase table, which will be the order you want this list to appear in the drop-down (make sure it is a number field):
Supply the numeric order:
In your other table, you can use the ID field from your t_Phase table by selecting it through the lookup wizard:
Move across the ID and the new "Order" field you just created:
Use the "Order" field as the field you want to use for sorting and make sure "Ascending" is selected:
Continue through the wizard:
Select the field that has the data you want to go in to the record of your table (I assume it's the ID field rather than the Order field, so make sure ID is selected):
Finish the lookup wizard and go in to Datasheet View on your table and check that the dropdown is now in numeric order. You've probably noticed a problem though as it is showing both the ID and the Order columns:
To hide the unnecessary Order column, go back in to Design View and click on your phase field to select it.
At the bottom should be a "Lookup" tab. Click on this and notice the Column Widths property... it's showing 2 different widths values; the first one is the ID field and the second one is the Order field. Set the Order field to 0cm to hide it. I'd then recommend setting the remaining Id field width to something that will be wide enough to show all your ID field's options. Then I'd set the List Width property to the same width.
8cm, for example:
This should result in something like the following, which is hopefully what you're after.
If you're not adding a lookup field to the design structure of a table, but are instead using a combo-box on a form or subform, the principle is pretty much the same; you'll just have to amend the combo-box properties from the form's Property Sheet "Format" tab instead:
Combo- and listboxes always contain text, thus your column is not sorted numeric.
To have a numeric sort, add a column with the number only and - in the source - sort only on that. If you don't the number separately, create it from this expression:
Val(Mid([PhaseField], 7))

Resources