Skip to main content
Solved

Add new row using Client script

  • December 20, 2023
  • 3 replies
  • 110 views

Forum|alt.badge.img+5

Hi Experts,

There is a requirement to create a new Row when user clicks on the ‘Restart’ button as below. I tried to achieve this using the below Client script code. 

 

CurrentScheduleType, currentScheduleRule, currentTaskTemplateId, startDate and productID values were taken from different logics and they were working fine. 

But I am currently facing an issue with the product_pm_id. My assumption was this field should populate (as a next sequence) when executing the addRowToFormDataList function. But as you can see, it is not populating any field value for product_pm_id. 

		var newRow = {
			product_pm_id: '',
			pm_schedule_type: currentScheduleType,
		    pm_schedule_rule: currentScheduleRule,
	        task_template_id: currentTaskTemplateID,
	        coverage_start_dt: startDate,
	        product_id: productID

		};



    addRowToFormDataList(dataList, newRow, true);

Any suggestions are highly appreciated.

 

Thanks,

Hasara

Best answer by Hasara Gunasiri

Hi @Shneor Cheshin,

 

This is already fixed with the below code.

It seems there is another UI level setting for the product_pm_id field. New product_pm_id generated during the saving after removing this UI level requirement.

		var dataList=getFormDataLists('c_product_pm_alias')[0];

		var currentScheduleType = getRowControlValue(selectedRows,'c_product_pm_alias','pm_schedule_type');
		var currentScheduleRule = getRowControlValue(selectedRows,'c_product_pm_alias','pm_schedule_rule');



		var newRow = {
			pm_schedule_type: currentScheduleType,
		    pm_schedule_rule: currentScheduleRule,
	        product_id: productID,

		};


    	addRowToFormDataList(dataList, newRow, true);

 

Thanks for the support.

 

Regards,

Hasara

View original
Did this topic help you find an answer to your question?

3 replies

Shneor Cheshin
Superhero (Employee)
Forum|alt.badge.img+28
  • Superhero (Employee)
  • 1138 replies
  • December 20, 2023

Hi @Hasara Gunasiri 

What is dataList? Can you share where you populate that variable?

As far as I understand you need to populate this with the following code

var dataList = getFormDataLists('table_name')[0];

where the table name is the specific table you are trying to add a record to.

Cheers!


Forum|alt.badge.img+5
  • Author
  • Sidekick (Customer)
  • 10 replies
  • December 21, 2023

Hi @Shneor Cheshin ,

 

Thank you for the reply.

dataList variable is already defined as below. But still getting the same  results.

 

var dataList=getFormDataLists('product_pm')[0];

Thanks,

Hasara

 

 

 

 


Forum|alt.badge.img+5
  • Author
  • Sidekick (Customer)
  • 10 replies
  • Answer
  • December 21, 2023

Hi @Shneor Cheshin,

 

This is already fixed with the below code.

It seems there is another UI level setting for the product_pm_id field. New product_pm_id generated during the saving after removing this UI level requirement.

		var dataList=getFormDataLists('c_product_pm_alias')[0];

		var currentScheduleType = getRowControlValue(selectedRows,'c_product_pm_alias','pm_schedule_type');
		var currentScheduleRule = getRowControlValue(selectedRows,'c_product_pm_alias','pm_schedule_rule');



		var newRow = {
			pm_schedule_type: currentScheduleType,
		    pm_schedule_rule: currentScheduleRule,
	        product_id: productID,

		};


    	addRowToFormDataList(dataList, newRow, true);

 

Thanks for the support.

 

Regards,

Hasara


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings