i have very, very simple logic hook- I am still learning and I am confused at the start.
I turn on Developer mode.
I already have field "FIRST_NAME" in Contacts module.
I Created my field "MY_FIELD" also in COntacts module.
In logic_hooks.php file I added
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'Value from one field to another', 'custom/modules/Contacts/my.php', 'User_hook','copy');
In my.php file I added
class User_hook {
function copy(&$bean, $event, $arguments)
{
$bean->my_field_c = $bean->fetched_row['first_name']. " - additional text";
}
}
So when I entered in First_Name value "First" I am getting in My field value "-additional text" but I should get "First- additional text."
If I go to Edit View and enter in First name field "Second" I am getting in My field value "First - additional text" but I should get "Second - additional text".
If I enetein Edit View "Third" I am getting in My field "Third - addiitional text" but I should get "Third - additional text".
So obviously my logic hook is executed with delay in one iteration- why and how to change it? This is my first hook so I am not so experience. Thanks for help
$bean->fetched_row['first_name'] will return the value of the field BEFORE you change it. You'd use this to see what the value of first_name was before the user changed it on the form.
Try using
class User_hook {
function copy(&$bean, $event, $arguments)
{
$bean->my_field_c = $bean->first_name. " - additional text";
}
}
Related
I have a js fiddle to show the issue that I am facing.
Tabulator 'email' column has freetext set to true to allow the user to set the value of the cell to a free text entry as follows:
editorParams:{
values:{
"steve#boberson.com":"steve",
"bob#jimmerson.com":"bob",
"jim#stevenson.com":"jim",
"harvy#david.com":"Harvy",
"ken#thompson.com":"Ken",
"denny#beckham.com":"Denny"
},
freetext:true,
searchFunc:function(term, values){
console.log("term and val "+term +" \n"+values);
var matchedEntries = {};
var matchFound = false;
for(var key in values) {
if(key.includes(term)){
matchFound = true;
matchedEntries[key] = values[key];
}
}
if(matchFound){
return matchedEntries;
}
else{
return {term: term};
}
}
}}
Select one of the values from the selector list displayed, say steve, value being 'steve#bobberson.com'.
Then after the value is selected, click on the same tabulator cell, the value displayed suddenly changes to the label.When user clicks enter key now, the label is selected instead of the value,.ie. steve will be displayed instead of steve#bobberson.com
If this is not a bug, how do I make sure that the value steve#bobberson.com remains selected after clicking enter. This is because freetext option is set to true in the editorParams of the column
Attached a gif showing the issue
That is not a bug,
With freetext enabled, users are able to enter any text they like in that field and it will be saved which is exactly what is happening in the example
If they select the email address again from the list then it is correctly saved.
It is an either/or scenario, you can either restrict the users to selecting specific values from the list OR you can allow them freetext in which case anything goes.
If you want a different behaviour then you can always build a custom editor that works in the way you want. Checkout the Custom Editor Documentation for more information
I have a very bland messagebox asking my users a simple question (not yes or no). For quick development I used a simple System.Windows.Forms.MessageBox and worded the question ("If you want to choose 'A' click 'Yes' if you want to choose 'B' click 'No'"). Now I'm going back and improving the look and feel of my wpf application and I'm stuck trying to convert this MessageBox into something that looks good.
My preliminary search told me to use Xceed.Wpf.Toolkit.MessageBox to be able to create custom message box but I'm getting an exception when I'm trying to use it.
Old Code
DialogResult dialogResultForDataDisplay = System.Windows.Forms.MessageBox.Show("Yes: Display by properties \n \t Each row will contain data for a specific asset class in a specific submarket during a specific quarter. \n \n No: Display by quarters \n \t Each row will will show the change over time for a specific property of an asset class in a specific submarket.", "Data Grouping Format", MessageBoxButtons.YesNo);
New Code
Style style = new Style();
style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.YesButtonContentProperty, "By Property"));
style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.NoButtonContentProperty, "By Quarter"));
MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show("How do you want your information displayed?", "My caption", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes, style);
Console.WriteLine(result);
The new code is generating this exception: System.InvalidOperationException: 'The calling thread must be STA, because many UI components require this.'
How would you go about handling this exception?
One solution I found now is rapping it in an invoke method. If someone has a better solution please post.
MessageBoxResult result = MessageBoxResult.None;
System.Windows.Application.Current.Dispatcher.Invoke((Action)delegate
{
Style style = new Style();
style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.YesButtonContentProperty, "Yes, FTW!"));
style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.NoButtonContentProperty, "Omg, no"));
result = Xceed.Wpf.Toolkit.MessageBox.Show("How do you want your information displayed?", "My caption", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes, style);
}
Console.WriteLine(result);
I have an application with grid of records and button insert. After clicking insert, there is a form, where you fill in data and click Ok for adding new record to the grid. After clicking Ok, there is validation which fires dialog with error informations, if any of the text fields do not match validation rules. Is there any posible way to test text on the dialog with textFx, if the dialog has no id?
This is an example for Alert based dialog:
In your test:
alert_dialog_has_header_and_content(
"Removing 'Almaty' location", "Are you sure to remove this record?");
In you helper test class:
public void alert_dialog_has_header_and_content(final String expectedHeader, final String expectedContent) {
final javafx.stage.Stage actualAlertDialog = getTopModalStage();
assertNotNull(actualAlertDialog);
final DialogPane dialogPane = (DialogPane) actualAlertDialog.getScene().getRoot();
assertEquals(expectedHeader, dialogPane.getHeaderText());
assertEquals(expectedContent, dialogPane.getContentText());
}
private javafx.stage.Stage getTopModalStage() {
// Get a list of windows but ordered from top[0] to bottom[n] ones.
// It is needed to get the first found modal window.
final List<Window> allWindows = new ArrayList<>(robot.robotContext().getWindowFinder().listWindows());
Collections.reverse(allWindows);
return (javafx.stage.Stage) allWindows
.stream()
.filter(window -> window instanceof javafx.stage.Stage)
.filter(window -> ((javafx.stage.Stage) window).getModality() == Modality.APPLICATION_MODAL)
.findFirst()
.orElse(null);
}
I know this issue is a little old and probably got fixed, but for documentation purpose in case someone else look for a fix for an issue alike, I see dialog.getDialogPane() in Dialog documentation, which would help lookup for specific controls inside the pane. So further on #plaidshirt query, we could retrieve buttons and input fields with:
dialog.getDialogPane().lookupAll()
Then narrow that down to buttons and input fields for example.
I am working on an application that uses Xpages and KendoUI. In one particular page I have a tool bar with a button with "Add Record". The button opens a window and the user will select one from a piece of data and that will create a new record.
The list of data are employee names and I must compute them. I do so in a sessionScope [could be viewScope] array in the beforePageLoad, like so:
<xp:this.beforePageLoad>
<![CDATA[#{javascript:viewScope.myArray = [];
viewScope.myArray.push("1st Val");
viewScope.myArray.push("2nd Val");
viewScope.myArray.push("3rd Val");}]]>
</xp:this.beforePageLoad>
The dropdown needs data in the following format:
var data = [
{ text: "Black", value: "1" },
{ text: "Orange", value: "2" },
{ text: "Grey", value: "3" }
];
For the life of me I cannot get the data into that format. It looks like a javascript object to me.
How do I get the array in the viewScope into the format I need?
var o = {};
o = "#{javascript:viewScope.get('myArray');";
All SSJS Array objects added to any of the scopes are converted to java.util.Vector (how to update a value in array scoped variable?) which can not be stringified with the standard toJson function. This can be circumvented by creating an intermediate object to store the array in:
viewScope.myData={myArray:[]};
viewScope.myData.myArray.push( { text : 'Mark' , value : '1' } );
viewScope.myData.myArray.push( { text : 'Bryan' , value : '2' } );
Also, I doubt your line of code returns the right data without any explicit JSON conversion. I would write it as:
var myArray = #{javascript:return toJson(viewScope.myData.myArray);};
When you set your client side js variable called o it's a string because the value is between "".
So just remove the double quotes and you'll get it as object.
o=#{javascript:viewScope.get('myArray')};
But be aware you might get an js client side error if the viewscope value is not a valid client side JS object !
You can also set the variable o to a string as you did in your example and use the eval clientside method to evaluate the string as an object.
o=eval("#{javascript:viewScope.get('myArray')}");
P.S. In your example there is a } missing is at the end of your SSJS code when you set your "o" variable.. ;-)
I want to insert in Accounts Receivable-> Settings -> Accounts Receivable Parameters (in form CustParameters) a new group with a new parameter field in the dialog of function Update quotation line.
When button Update Quotation Line is clicked, it opens a dialog.
I inserted a new field, I modified method getFieldDescripion in class SalesQuotationToLineField.
This works, I have the new parameter, but I do not have a Group .
I want a group with a label like in the following screenshot, but with my label (field-Label). What do I have to change to achieve this?
Thanks all!
enjoy!
If I understand your question correctly, you added a new field to the dialog "Update sales quotation line" that can be called from form CustParameters and now you want to change the label of the group of this new field.
To do this, you have to overwrite method fieldGroupLabel of class SalesQuotationToLineField and add a switch similar to method getFieldDescription to test for the new field and return a custom label in that case. This overwritten method will be called by method dialog in class SalesPurchTableToLineParametersForm.
The overwritten fieldGroupLabel should look similar to the following example:
public FieldLabel fieldGroupLabel()
{
FieldLabel ret;
ret = super();
switch (this.parmFieldId())
{
case fieldNum(SalesQuotationTable, SalesGroup): // replace this with the new field
ret = 'My Group label'; // replace this with the id of the label you want to use
break;
}
return ret;
}