NetSuite sublist column order (suitescript 2) - suitescript2.0

Is there any way to add a sublist field via a user event script and define its column position? By default the field is added as the last column. It appears you can move form fields around, but can't change sublist column order.

We can able to edit sublist column postion.
But it can be vary based on your records either transaction or suitlet script or any other things just elaborate your question pls.

// For This Example we create a first Field
var field1 = form.addField({
id : 'textfield1',
type : serverWidget.FieldType.TEXT,
label : 'Text'
});
// For This Example we create a first Field
var field2 = form.addField({
id : 'textfield2',
type : serverWidget.FieldType.TEXT,
label : 'Text'
});
form.insertField({
field : field2,
nextfield : 'textfield1'
});

Related

cmd_ei_api=>maintain_bapi to update kna1 table field (ICMSTAXPAY)

I have a requirement to update this field ICMSTAXPAY in KNA1 table using my custom report. So, I tried using cmd_ei_api=>maintain_bapi to update the table. But once I run the program, that particular field is not updated and I don't get any error messages too.
My logic:
Read the KNA1 entries.
Edit the required field to my value.
Pass mandatory data to HEADER for update.
Pass my new KNA1 entries to CENTRAL_DATA.
Read data from table:
CALL METHOD cmd_ei_api_memory=>get_global_kna1
EXPORTING
iv_kunnr = <lfs_final>-kunnr
IMPORTING
es_kna1_old = ls_old.
Change the value of field:
ls_old-icmstaxpay = 9.
MOVE-CORRESPONDING ls_old TO ls_customer-central_data-central-data.
Assign header data:
ls_customer-header-object_instance-kunnr = <lfs_final>-kunnr.
ls_customer-header-object_task = 'U'.
Add all the above to the master data structure:
APPEND ls_customer TO lt_customers[].
ls_master_data-customers = lt_customers[].
Pass the data and update to table:
cmd_ei_api=>initialize( ).
LOOP AT lt_customers INTO ls_customer.
cmd_ei_api=>lock( iv_kunnr = ls_customer-header-object_instance-kunnr ).
ENDLOOP.
" Update Customer with CMD_EI_API
CALL METHOD cmd_ei_api=>maintain_bapi
EXPORTING
iv_test_run = space
is_master_data = ls_master_data
IMPORTING
es_message_defective = ls_message_defective.
IF ls_message_defective IS INITIAL.
BREAK-POINT.
COMMIT WORK.
ELSE.
BREAK-POINT.
ENDIF.
LOOP AT lt_customers INTO ls_customer.
cmd_ei_api=>unlock( iv_kunnr = ls_customer-header-object_instance-kunnr ) .
ENDLOOP.
When I debug, I can see that the entry that is being fetched for update is the old entry that is present in the current memory.
Please let me know if i am doing something wrong while passing the value to the table.
You need including DATAX with X for all fields that you need change.
DATA: ls_datax TYPE cmds_ei_vmd_central_data_xflag.
ls_datax-icmstaxpay = 'X'.
MOVE ls_datax TO ls_customer-central_data-central-datax.
And thanx for your question, helped me with find this methody :)

How to add checkbox column in vue-tables-2?

I have list of users table created in vue-tables-2. I want to add checkbox column before each row to select multiple row and before header to select all row like gmail.
can anyone help me out ?
it is very simple.
you should add a column to your vuetables column, just this.
imagine you are defining your tables column in fileds variable.ok ?
i mean something like below,just put this code inside your table coulmn:
fields: [
{
name: '__checkbox',
titleClass: 'center aligned',
dataClass: 'center aligned'
},
//...
]
if you wana get more information take look at this link:
https://github.com/ratiw/vuetable-2-tutorial/wiki/lesson-11

How to write database/SQL query in Yii2, with and without a model

I have a table with multiple column and I want to return a column name using another column name as search criteria. How do I achieve this in yii2?
Below is sample code, normal sql should be:
$name = SELECT type_name FROM ProductTable WHERE type_id = 1;
echo $name;
This should return the value of the column type_name where the value of the column type_id equals 1. I tried this, but it doesn't work
$type_name = ProductTable::find()->where(['type_id' =>$model->type_id]);
$type_name = Product::find(['type_name'])->where(['type_id' =>$model->type_id]);
I also tried this, but I guess it was wrong
I hope my question is clear enough and any help will he appreciated
and u could also use createCommand!
$name = \Yii::$app->getDb()->createCommand("SELECT type_name FROM ProductTable WHERE type_id=:typeId", ['typeId'=>$model->type_id])->queryAll();
For a general introduction to Yii2's ActiveRecord, see the guide: http://www.yiiframework.com/doc-2.0/guide-db-active-record.html
If you want the complete row and have a model, you're just missing a one():
Product::find()->where(['type_id' =>$model->type_id])->one();
If you do have a Model defined and just want a single value, try:
Product::find()->select('type_name')->where(['type_id' =>$model->type_id])->scalar();
Which basically generates an ActiveQuery via the model, and changes it to return only the first column in the first row of matched results.
If you do NOT have a model, you could also generate a normal query without ActiveRecord usage (http://www.yiiframework.com/doc-2.0/yii-db-query.html)
$name = (new Query())->select('type_name')
->from('ProductTable')
->where(['type_id' =>$model->type_id])
->scalar();
I assume you generated ProductTable by using Gii module.
Also, if type_id column is a primary key:
$product = ProductTable::findOne($model->type_id);
if($product !== null) { $product->typeName /*... read value ...*/}
or to get all records
$products = ProductTable::findAll($model->type_id); //match all records.
for any other column use the following syntax instead:
$product = ProductTable::findOne(['type_id' => $model->type_id]);
Use following code to get type_name
$PTable=ProductTable::find()->select('type_name')->where(['type_id' =>$model->type_id])->one();
echo $PTable->type_name;

Change field length afterwards

TABLES: VBRK.
DATA: BEGIN OF it_test,
BUKRS LIKE VBRK-BUKRS,
FKDAT LIKE VBRK-FKDAT,
END OF it_test.
DATA: wa_test LIKE it_test.
SELECT * FROM VBRK INTO CORRESPONDING FIELD OF wa_test.
IF wa_test-BUKRS = 'xxxx'.
wa_test-BUKRS = 'XXXXX' "Problem occurs here as the BUKRS allow 4 value
APPEND wa_test TO it_test.
ENDIF.
Then I want to map the internal table to output as ALV table. Is they any way to change the field length afterwards?
Apart from multiple issues in your code, you can't. If you need something similar to that, add an additional field to the structure with whatever size you require and copy the values over.
If the objective is to output something to the screen that is different(or differently formatted) that what is stored internally(or in the database), then the use of a data element with a conversion exit maybe the way to go.
For an example, look at the key fields of table PRPS.
Expanding the answer of vwegert:
The MOVE-CORRESPONDINGcommand (and SELECT ... INTO CORRESPONDING FIELDS) don't need the same field type. The content is converted. So you could define a 5-character field in your internal structure and copy the BUKRS-value into this 5-character field:
TABLES: VBRK.
DATA: BEGIN OF it_test,
BUKRS(5), "longer version of VBRK-BUKRS,
FKDAT LIKE VBRK-FKDAT,
END OF it_test.
DATA: tt_test TYPE STANDARD TABLE OF it_test.
* I would strongly recommend to set a filter!
SELECT * FROM VBRK INTO CORRESPONDING FIELD OF it_test.
IF it_test-BUKRS = 'xxxx'.
it_test-BUKRS = 'XXXXX'.
APPEND it_test to tt_test.
ENDIF.
ENDSELECT.
A pitfall: When you use it with ALV you will loose the field description. (on the other side, the field description of the original field will not fit any longer the new field.)

CHtml::listData findall returns last element

I have a dropdown list. Within the dropdownlist, I use listdata to retrieve the data from another table. But strangely, it only gets the last item in the table.
$form->dropDownList($model,'status_id',CHtml::listData(OrderStatus::model()->findAll(),'status_id', 'status'))
chtml::listdata strangely only shows this array(1) { [""]=> string(9) "Delivered" } while in the table there are 7 rows/id, where delivered is the last entry. What happened to the others?
Another odd thing is that $model->status_id is actually id 1, so it shouldn't display 'Delivered', it should be showing 'New'.
Take a look at this:
Example 1: Generating a list data for categories
// you can use here any find method you think proper to return your data from db*/
$models = categories::model()->findAll();
// format models resulting using listData
$list = CHtml::listData($models, 'category_id', 'category_name');
print_r($list);
HTML Output (Example):
array("1" => "Arts", "2" => "Science", "3" => "Culture");
See if you have by any chance a default scope.
Just do a debug of OrderStatus::model()->findAll() and see if it returns 7 records or just 1.
Your chtml::listdata strangely showing
array(1) { [""]=> string(9) "Delivered" }
Is because you must have same entries in status_id column of all the rows in OrderStatus which is blank/null as per above array.
In below call
CHtml::listData(OrderStatus::model()->findAll(),'status_id', 'status')
status_id is key( index of array ) for your generated list array & its getting overwritten by same value everytime, thats whay its showing only one & last value.