How to trigger an action when deleting value from an autocomplete field on Apex 18.2 - oracle-apex-18.2

I have created an autocomplete item on my page and i want to trigger the change on this field. I am using Apex 18.2 and for the autocomplete item i have used a dynamic action with event Update [Text field with autocomplete].
This works fine when i change the value from the autocomplete and put another value from the list, but if i want to delete the value, the DA is not triggered.
I have tried also ojupdate custom event, but the same problem.
I have tried event change when item is null, but no success.
What i want to do is when deleting the value from the item (when item is null) to trigger an action.
Is there a DA that can help me on this particular issue?
Item: P37_ART
Type: Text field with autocomplete
Settings: Contains & Ignore Case
Lazy Loading: YES
Maximum values in List: 20
Item based on SQL Query and the format is number1||' - '||text1
Example: 1245 - Groceries
Dynamic Action:
Event: Update [Text field with autocomplete]
Action: Execute Javascript code
alert('test');

create another dynamic action thats has client side condition type javascript condition and check if your Text field is empty or is null using JS code, for example:
document.getElementById("textfield").value == "" || document.getElementById("textfield").value.length == 0 || document.getElementById("textfield").value== null

Related

How to move sublist fields created from User Event script

I added a sublist field on a transaction. For instance a Sales Order. When you add the field via user event script, it positions the field at the end of the sublist. Is there a way to position the field? This can't be accomplished in the UI as the field is added via script. It's a select type field, so I am trying to modify the list values with client script and can only do that if the field is created in my user even script. My code works perfectly fine, it's just the field is at the end of the sublist line(far right and have to scroll). I am using SuiteScript 1.0 but am open to using 2.0 if I need to.
This is for suitescript 2.0
This has sort of turned into two questions so I will give an answer for one and then the solution, for clarity. The short answer is you cannot move a sublist field when created in a user event (however there is a solution to that.)
you can add a sublist field by getting the sublist and using the sublist.addField method.
function beforeLoad(context){
var form = context.form;
var sublist = form.getSublist({
id : 'item'
});
sublist.addField({
id: 'fieldid you want to use for script reference ect.',
type: serverWidget.FieldType.CHECKBOX, //any supported TYPE
label: 'Label users will see in sublist'
});
}
If done this way, there will be a new column on the end of the items sublist that cannot be moved.
To be able to move the location of the column do the following.
Navigate to
Customization
Lists, Records, & Fields
Transaction Line Fields
add a new field and apply to the sublist you want it used on.
you can assign and id which will be prefixed with custcol so start your id with an _ and give it a name.
Once this is complete you can access the field by id and change the value in your user event script before load
function beforeLoad(context){
var form = context.form;
var sublist = form.getSublist({
id : 'item'
});
sublist.setSublistValue({
id: 'customcol_id_created_in_ui',
line: 1, //line you want to access if needing to set all you will have to loop through and set each one.
value: "your value"
});
}
If you go to the API reference and look at the ui/serverWidget module and navigate to sublist you can find all of the methods and options for manipulating sublist there.
In SuiteScript 2.x you would use the N/ui/serverWidget module, create the field and then use the Form.insertField(options) method, passing in the field you created as options.field and the existing field which you want to insert your field before as options.nextfield. Note that Form refers to the form object passed to the user event script in the scriptContext.
i don't believe there is a SS1.0 equivalent.

Clearing previously set value from Selector Editor

New to Tabulator, it's awesome! Have an issue on a Select editor. I am populating from a AJAX feed from API/DB. But my values don't have a "none" option. So I need to be able to clear the current value to "unselect" it. Eg set the DB value back to Null / None.
I can't see a way to do that on the Select editor? What's the most efficient way to clear the current value.
You should add a blank entry to your values object in the editorParams property of the column definition
{title:"Gender", field:"gender", editor:"select", editorParams:{
values:{
"":"", //clear cell value
"male":"Male",
"female":"Female",
}}
},

Kentico Admin - Dynamically Change and SAVE Field Name, Value and Label

For a custom page type, I have a multiple choice form filed as seen in image 1 and 2. I was able to set it up (using jquery) so that when I click on other checkboxes belonging to a another field, the checkbox Label and value of this field is changed accordingly as seen in image 3 - 'Author1', 'Author2', 'Author3' were replaced with something else.
The problem is when I hit the Save button, all of my new label/value are not Saved, but the checkbox value and label return to its original value.
Is there a way to make it so that these checkboxes can accept new value and the new value can be saved. Thanks!
Where does authors values come from? Database? You should be able to use SQL query as data source for multiple choice control. This will allow you to store actual values into database whenever you save a page on the Form tab.
So the idea is to load actual values, replace them with 'AuthorN' and change back to original value when checked.
I've set up an example which might help you. I've created a form with three fields:
FirstAuthor
Type: Integer
Form control: Radio buttons
Data source: SQL Query (select userid,username from cms_user)
Has depending fields: true
SecondAuthor
Type: Integer
Form control: Radio buttons
Data source: SQL Query (select userid,username from cms_user)
Has depending fields: true
OrderedAuthors
Type: Text (1000)
Form control: Label
Default value: {% (if(firstauthor>0) { GlobalObjects.Users.Where("userid="+firstauthor)[0].UserName } else {""}) + ", " + (if(secondauthor>0) {GlobalObjects.Users.Where("userid="+secondauthor)[0].UserName} else {""} #%}
Depends on another field: true
I guess you have a list of authors somewhere in the database so you can just replace CMS_User table with your table. Then all you need to do is to adjust the macro in the third field to give you results you want.

Delete a field value based on checkbox-Netsuite

I have a requirement where if the user unchecks the checkbox the vale of certain field should be cleared while he saves it.
To be printed is a checkbox
Check # is field.
If the user unchecks the "To be Printed" checkbox the check # field should be clear while he saves the page.
This should be a user event and will be it be after submit funtion?
How do i achieve this?
Here you have two options to deal with your requirement.
1) You can write a Client script as #John mentioned above on his comment and on field change you can clear out those field values which you don't want to save upon your form submission.
2) Write a before submit function and validate the checkbox field value, if it is unchecked then clear out those fields, which you don't want to save.
I would recommend using user event before submit script to set field value as null, as client script may not fire if data entry point is through csv import, suitescript, etc.
if (nlapiGetFieldValue(TO_BE_SUBMITTED_FIELD_ID) == 'F'){
nlapiSetFieldValue('tranid', null);`
}
If you wish, You may write additional client script to disable/clear the field if value of checkbox is set to false, for better UX.
For sequence number I would say, use the below code (I am assuming sequence numbers are pure numbers)
if (nlapiGetFieldValue(TO_BE_SUBMITTED_FIELD_ID) == 'T'){
//search in descending order (use this code in your same before submit script)
var search = nlapiCreateSearch(RECORD_TYPE, ['mainline', 'is', 'T'], new nlobjSearchColumn('tranid').setSort(true));
var results = search.runSearch();
var records = results.getResults(0, 1);
var nextTranId = praseInt(records[0].getFieldValue('tranid'), 10) + 1;
nlapiSetFieldValue(tranid, nextTranId);
}

fieldChanged function in netsuite

Field Changed Function
If the value in a text field is changed to the same value (example: old value = "ABC", new value = "ABC"), will the script
Field Changed Function fire or not?
nlapiSetFieldValue
Some additional information:
FieldName:
String - the name of the field being set
value: String - the value the field is being set to
firefieldchanged: Boolen - if true then the fieldchange script for
that field is executed. (Only available in Client SuiteScript)
Sets the value of the given field.
This API can be used during beforeLoad scripts to initialize field scripts on new records or non-stored fields.
nlapiSetFieldValue is available only in Client and User Event SuiteScripts.
Whenever you are changing the value of an textfield, you will call the fieldChanged event even if you are staying with the same name as you had before.
If you are asking about the Client Side script event Field Change, if I recall correctly this will only trigger when the user has changed the value of the field in the UI. But this event can also be triggered by the nlapiSetFieldValue and nlapiSetCurrentLineItemValue if the fireFieldChange parameter is set to True.

Resources