How to save a record in table on Ax Form in a button click event? - x++

I am new to AX, and I am struggling with the basics.
My requirement is to save the record in a table from form controls on a button click event. What is the best approach?
Because I also see "Override" method "CreateRecord". If I go with "CreateRecord" method, then is it possible invoke the method in "Button Click Event"?

In form you need to add a Button, then expand, right click in methods, Override method and select Clicked.
Here put your code, For example:
void clicked()
{
TableExample TableExample;
;
TableExample.clear();//clear fields
TableExample.Field1 = "Your Value 1";
TableExample.Field2 = "Your Value 2";
TableExample.Field3 = "Your Value 3";
TableExample.Field4 = "Your Value 4";
TableExample.Insert();//Insert in table
info("Record create");//Display a message (Optional, only an example)
super();
}

Related

Vaadin grid - change component column in one row only

I have a grid with several columns. For three columns i used the column renderer. Each of the columns contains one button.
If i click one of those buttons, i want to replace the three buttons in that specific row with two other buttons. All the other rows should not be affected. Is this possible in a Vaadin grid?
Components in different columns don't know each other, as they are all defined in a separate scope (in the componentRenderer of their own column. You cannot define the Button outside of the componentRenderer as you found out in another question today). So the "obvious" solution won't work, where you add a clickListener on the Button to directly change the other buttons.
If you had one column with 3 Buttons inside then this would be much easier.
There is a way, but I see this more as a hack than as a solution. Because you need some extra implementation in the item class for this to work.
In the ComponentRenderer, you can add an if-statement where you look at some value of the item. In one case, you'll render button 1, in the other case you'll render the other button. And in the click listeners of the button you change that value in the item and refresh the dataprovider, so the componentRenderer is invoked again. It will now see the value on the item has changed, therefore displaying some other Button.
Here is some code to show what I mean:
// grid item class
public class Foo {
private boolean buttonPressed = false;
public Foo(){
}
public isButtonPressed(){
return buttonPressed;
}
public setButtonPressed(boolean buttonPressed){
this.buttonPressed = buttonPressed;
}
}
// adding of button columns
// do this 3 times for a test of your scenario.
grid.addComponentColumn(item -> {
if(!item.isButtonPressed()){
return new Button("Before Button was Pressed", click -> {
item.setButtonPressed(true);
grid.getDataProvider().refresh(item);
});
} else {
return new Button("Button was Pressed", click -> {
item.setButtonPressed(false);
grid.getDataProvider().refresh(item);
})
}
})

How can I like and retwweet with cefsharp?

I am trying to send a like and a retweet command to a twitter page, with cefsharp, but my tries don't work any more until now.
The like button has 'ProfileTweet-actionButton js-actionButton js-actionFavorite' as button class name.
The tweet buutton has 'ProfileTweet-actionButton js-actionButton js-actionRetweet' as classname : that opens a window with a button having 'EdgeButton EdgeButton--primary retweet-action' as class name.
string click = "document.getElementsByClassName('EdgeButton EdgeButton--primary retweet-action')[0].submit();"; //.button();"; //ProfileTweet-actionButton js-actionButton js-actionRetweet
Task<JavascriptResponse> response = browser.EvaluateScriptAsync(click);
click = "document.getElementsByClassName('ProfileTweet-actionButton js-actionButton js-actionFavorite')[0].submit();"; //.button();";
response = browser.EvaluateScriptAsync(click);
gives a {not yet computed} Task.result, and button() instead of submit() methods give the same result.
Perhaps the do-undo buttons add a layer of something, to click on them ?
Tx a lot for your tips/ideas, in all cases.

UILabel text changing between two strings with each "touch up inside"

I'm learning OBJ.C/Xcode/Cocoa here and have run into a question I can't seem to find an answer for.
I want the text in a UILabel to switch between two states (ON/OFF for example) each time the user clicks the same button.
I can get the label to switch to one state, but can't get it to switch "back" when the user clicks the button again. I am assuming there is some logic required, or checking the status of the object once the button is clicked...
Does this require me to keep track of a bool or the "state" of the Label (or button)?
Would this require two methods to be associated to the button, or can it happen with just one?
Thanks for any guidance/pointing in the right direction/Code snips!!!!
~Steve
I got an answer, and it works:
- (IBAction)flip:(id)sender
{
_flipButton.selected = !_flipButton.selected;
self.flipLabel.text = (_flipButton.selected) ? #"ON" : #"OFF";
}
- (IBAction)flip:(id)sender {
[yourButton setSelected:!yourButton.selected];
self.flipLabel.text = (yourButton.selected) ? #"ON" : #"OFF";
}
This toggles the selected state of the button then checks its state to determine which string to pass to the text property of your label.
the easiest way (I think) is to store a BOOL with the state of the UILabel and (on each click of the button) negate the BOOL and set the appropriate text of the Label
You could call this: yourLabel.enabled = !yourLabel.enabled on button click to change the enabled-state of your UILabel. Or what kind of state do you mean ?

When box is checked make a drop down readonly or uneditable in Rails

I have a drop down box in ruby on rails that allows a date to be entered. And there is a box beside it to indicate that no date will be entered.
When this box is ticked it changes the default value of the date to nil. However the user can still enter a date on the drop down boxes.
When the box is ticked I want the drop down to be readonly or uneditable how can I do this?
EDIT
function BlankOutStartDates() {
if (document.getElementById("service_unknown_start_date").checked == true)
{
document.getElementById("service_start_date_1i").selectedIndex = 0;
document.getElementById("service_start_date_2i").selectedIndex = 0;
document.getElementById("service_start_date_3i").selectedIndex = 0;
}
}
I want to add the addition javascript to make the drop down box read only if the box is ticket
I would actually do this in jQuery. Suppose your checkbox has class "no-date", and your select boxes all of the class "date-select". Then you could do this:
jQuery(".no-date").change(function(){
//Check if the box is checked
if(this.is(':checked')){
jQuery(".date-select").attr("disabled", "true");
} else {
jQuery(".date-select").removeAttr("disabled");
}
});
You'll want to double check "this.is(':checked')" is correct, but I think that will work.
This uses the "disabled" parameter of select tags: http://www.w3schools.com/tags/tag_select.asp

text field in a dialog box on a BlackBerry

I want to create an empty dialog box with a text field inside. When the user enters data inside the box he must be redirected to another screen. I want the Dialog box to come up without any statements but must include a textfield
That should be doable with a PopupScreen, EditField and maybe a ButtonField so the user can let you know he/she is done entering data.
Just create standard OK dialog and then add an EditField to it.
BasicEditField inputField = new BasicEditField();
Dialog d = new Dialog(Dialog.D_OK_CANCEL, "Enter your Username:", Dialog.OK, null, Dialog.DEFAULT_CLOSE);
d.add(inputField);
int i = d.doModal();
if (i == Dialog.OK) {
Dialog.inform("Your Username is : " + inputField.getText());
}
Here's a complete tutorial

Resources