Skip to main content

There is a requirement to limit drop down of Task-Template on contract-pm based on value of “Brand” field on Contract Product.

Eg.

Contract Product has Brand = A5

User-Def1 of Task Template = A5

In Contract PM only Task-Template (which has user-def1 = A5) will be populated

 

 

There are 5 task-templates which connected to brand (user-def1 value) = A5

 

Expected result: the task-template in Contract Product\PM only shows those 6 task-templates.

(not all templates like currently)

 

 

I tried to setup using “Lookup XML” of field task_template but could not get correct connection and contraint.

 

I tried using client-script and set it on screen, event = AfterDataLoad and not succeed either.

Client-script looks like this:

showProgressIndicator();
var prodBrand = getControlValue('contr_product','brand');
// alert('brand = ' + prodBrand);
var emptyOptions = ];
var options = createCodeTableOption('', '');
arrayPush(emptyOptions, options);
setControlOptions('contr_pm', 'task_template_id', emptyOptions);
var opt = n];
var taskTemp = null;
var tempId = null;
var tempDesc = null;

var taskTemplates = getDBValues('C_GET_TASK_TEMPLATE', aprodBrand]);
// alert('size task template ' + size(taskTemplates));
for (index = 0; index < size(taskTemplates); ++index)
{
    taskTemp = taskTemplatesrindex];
    tempId = taskTemp.task_template_id;
    tempDesc = taskTemp.description; 
    arrayPush(opt, createCodeTableOption(tempId, tempDesc));
    
}
setControlOptions('contr_pm', 'task_template_id', opt);
hideProgressIndicator;

 

Client-script SQL C_GET_TASK_TEMPLATE':

SELECT task_template_id, description FROM task_template WHERE user_def1 = '{0}'

 

I can get the correct task-template.  But the contr_pm.task_template_id is still populating all templates.

 

Any suggestion to achieve the above requirement?  Either only with configuration on screen or using client-script?

 

Thanks in advance.

~Juni

Hey @JuniSihombing 

What is the tab ‘PMs’? I cannot see it in the baseline system I have.

I believe you are either trying to populate a wrong field or have a wrong syntax.

Option 1: Your line below is pointing to the wrong control. It is hard to say what is the correct control, as I can’t see ‘PMs’ on my end.

setControlOptions('contr_pm', 'task_template_id', opt);

Option 2:

Your syntax is off, Try the following

    tempId = taskTemp "task_template_id"];
tempDesc = taskTemp "description"];

 

Cheers!


Hi @Shneor Cheshin,

thanks for your response.

 

The Option 2 you gave also doesn’t work.
Actually the syntax I put correct.  I tested it by putting the value to field “Line Status” (setControlOptions('contr_pm', 'task_template_id', opt);

the correct task-templates shown on “Line Status” dropdown.

 

The “PMs” tab is custom tab on custom CONTRPRODUCT screen.

Yes, the setControlOptions('contr_pm', 'task_template_id', opt); is wrong control.

How can I get/set the control to “contr_pm” (PMs tab)?

 

 


Hey @JuniSihombing 

You are trying to update a selected row, and not the main header. Hence your method will fail to work.

The ‘Line Status’ filed is on your header, so you see the expected results. The ‘Template ID’ field is on a tab, so this will not work for you as you think it should.

If it was a single value, you would have used 

setValueOnListDataRow(row: ListGroupRowData, tableName: string, columnName: string, value);

But it is an array of values you are trying to populate on the control.

I suggest changing the control to be a lookup (not drop-down) and set the default search values in the lookup screen.

Personally, I could not set values of an array like in the header part of the screen. Only a single value. Maybe someone else knows a method to achieve this?!

Cheers!


Thanks for the feedback, @Shneor Cheshin.

Indeed, it’s not for updating the record, but to populate selected array for the contr_pm.task_template_id control.


Hi @JuniSihombing,

did you get a solution for your problem?
We are facing a similar requirement in the part-need tab in requests. We try to limit the options for the field/dropdown part_line_code based on the request-type. So if you found a solution i were very pleased if you can share the solution with us :)

Thanks


Hi @BSiemund,

unfortunately, I didn’t get solution for that requirement.  So, we just lookup all the task-templates.

 

Best regards,

~Juni


Hi @JuniSihombing,

thanks for your quick feedback. 

Best regards


Reply