Something like setVisible() for Dynamics AX 2012 - axapta

Is there any way to do that?
I mean, if the form fullfill specific conditions setVisible true or false to a control in the form? Or if i check a CheckBox, show some specific ComboBox?
Thanks in advance for your help

I would recommend enabling and disabling fields, rather than hiding them.
Open a Supplier, and on the Invoice and Delivery fast tab choose select the Calculate withholding tax CheckBox. This is the VendTable form.
The Calculate withholding tax control will enable and disable a second control depending upon the value selected.
The second control has it's property AutoDeclaration set to Yes, and the event that fires the change can be found on the forms VendTable data source. Find the relevant field (VendTable > Data Sources > Vend Table > Fields > TaxWithholdCalculate) and notice that the modified method has been overridden, changing the control's enabled property. It also has a visible property should you want to remove it from view.
Top Tip: In case that you are not aware, you can right click on any control on a form and choose the Personalise option from the context menu. From there is a form which contains a very useful box called System name. You can find the name of the control/table field from this.

I suggest you this solution for your second problem:
if i check a CheckBox, show some specific ComboBox?
I assume your form is complete (it has all controls needed : comboboxes, checkboxes, etc). And the controls AutoDeclaration-property is set to 'Yes'.
In the AOT expand the Form till you find the CheckBox, expand it as well
Right-click its Methods and select 'Override method' >> 'Clicked'
Finally you can add this code and save/compile the form:
myComboBox.visible(true);
It should look like:
public void clicked()
{
super();
myComboBox.visible(true);
}

Related

Uneditable box after ticking it

How can I make it after ticking the box and it turns uneditable right away?
This question is somewhat loaded because the answer is, it depends.
Your screenshot makes it look like that control is in a grid row, which would imply the control is connected to a datasource. If that's the case, do you want only the checkbox to be disabled or the entire row?
You would probably put code in the datasource field's modified method or the datasource's active method.
If the checkbox is a standalone control, you would override the clicked method with something like:
public void clicked()
{
super();
if (this.checked())
this.enabled(false);
}
I believe it's due to Field properties in table.
Seems like it restricts edit after creation.
Otherwise - check code on form (or class maintaining the form). It might be on Control/Field/Datasource/Table modify method.

set default value for detail in master/detail relationship form widget dialog button

I have a master/detail relation similar to the relations sample provided.
In my example department has a one to many relationship with employee
I have a form widget(department) which has a button to insert an employee.
when I click on that button the correct dialog form is displayed but I am allowed to enter any department which I do not want.
I am looking to have the relation defaulted to the "parent" widget where it was clicked and ideally not be editable.
It's hard to give an exact answer without seeing your app, but you should probably replace the dropdown in the form with a label, that will make it not editable. You can bind the value of the label to the relation just like the value of the dropdown was bound.
A slightly easier option would be disabling the dropdown (look for the Enabled probably in the property inspector). But that could be confusing for your users since they might think it should be editable.
(Alternatively, you could just remove the field altogether if it's not important to show the relation.)
I think this only answers the "not editable" part of your question, if you want it to be pre-filled you either need to do some scripting, or use relation data sources.
I suggest using relation data sources, so right now you probably have something like:
app.datasources.Emp.create(), which creates a new employee.
Instead, you can use widget.datasource.relations.Emp.create(), which will create a new employee which has a relation to the current item in widget.datasource. If this button is placed in your department form widget, then that means it will create an employee related to whatever department is shown in the form.
Note that none of this stops users from changing the department of an employee, it just changes the UI. In lots of cases that is enough, but you may also want to add some server-side security controls if it's important to limit which users can create employees, change departments, etc: See https://developers.google.com/appmaker/security/secure-app-data

Using bindings with BrazosUI buttons

I'm used to using boolean bindings with IBM buttons to track if a button is clicked. The button in Brazos UI can be bound to any variable type but doesn't make automatic updates to booleans. How do I use bindings with Brazos UI buttons to track which was last-clicked?
The binding of a button is really only useful in tables. The acceptance of ANY variable type for the binding of a button stems from the use of determining the index of a selected row or obtaining the entire row object:
If you bind and integer to the button in a table, the binding will update with the index of the row when the button is clicked.
If you bind a variable of the same (singular) type as the table's binding, then clicking the button will update the binding with that row's data.
Both of those are handy interactions with the table control but don't work for tracking which button is clicked when used elsewhere on a coach. For that, you want to utilize the 'Button Control ID' configuration option. The most direct method is to bind the same string variable to all of the buttons you need to track. When clicked, a button will update that shared variable to match its own control ID. You can then use that unique ID in various scripting checks to take button-specific actions.
See the BP3 Help Center article for greater detail about this, including some examples: https://support.bp-3.com/hc/en-us/articles/217985767-Using-Button-Binding-with-Brazos-UI

Populate Data for TextField on change of LinkField in Magnolia

I have a CompositeField consisting of a LinkField and TextField in my dialog.
On select of data for LinkField, I want to populate the TextField also with a value related to the LinkField value.
Any idea how to do this?
This is for Magnolia CMS. I'm using the latest Magnolia version.
Thanks! :)
There is no ootb binding between different fields.
To create it, you would either need to write your own field that will internally encapsulate the link field and text field and register listener for link field value change and upon change set value for the text field.
Or you would need to rewrite dialog presenter to be able to register such listener on the link field when it's being created.
Sorry, don't have any code samples at the moment to demonstrate it. Hope the explanation is clear enough.
HTH,
Jan
Do you need to update the text field in view of the editor?
If not, this can be easily achieved by modifying the save action. Your form should have a commit button defined with class=info.magnolia.ui.admincentral.dialog.action.SaveDialogActionDefinition
Open SaveDialogActionDefinition and you'll see it points to info.magnolia.ui.admincentral.dialog.action.SaveDialogAction which, when executed, can manipulate the node before saving the session.
If you extended SaveDialogAction, added another method similar to setNodeName(Node node, JcrNodeAdapter item) and called it between setNodeName(...) and node.getSession().save(), you could set any additional property you wanted based on those entered by the user.
You would also need another definition class that referenced your new action so your dialog definition knew to use the new action on commit.

Is it possible to catch a comboBoxes value before change with a change event

I am displaying a combo box in something of a WYSIWYG preview. I want the user to be able to click on the combo box and see the options inside, but I don't want them to be able to change the value. I tried using preventDefault() on the change event but it doesn't work. I don't want to disable it because I do want the user to be able to "look inside" the dropdown.
So I'm trying to block the change, but can't. My next resort is to change the selected index back to what it was before the change, Is there any way to do this within the scope of a ListEvent.CHANGE event listener?
Current Workaround is to basically re-assign the controls selected item the same way I am defining the selected item when I originally build it (a default selection). So a user sees their change then it immediately changes back to the default selection.
Are you sure that a combobox is what you want? could you do the same thing with a list component that is not selectable?
update:
If you must use a combobox and you dont want the lag from listening for the event and resetting the control, I see two possible options. You could subclass the control and make your own. When you do, hijack any methods that set the value besides the initial selection.
Or, you could try something like this: http://wmcai.blog.163.com/blog/static/4802420088945053961/. The site seems like it is in another language but the code is still there. It will allow you to make your options disabled, so the user cannot choose one of the other options.
HTH

Resources