Autopopulate multi-row variable set through Widget

Swathi P
Tera Guru

Hi All,

I am trying to autopopulate multi -row variable set through widget. I have added the below script in client controller. I am unable to set the variables in variable sets. Please help. i am doing anything wrong here.

var my_varset_three_way = $scope.page.g_form.getField("invoice_line_items");
      
        for (var sKey in details) {
            if (sKey == "invoice_line_items") {
                alert(sKey);
                alert($scope.page.g_form.getValue(sKey));
                $scope.page.g_form.setValue(sKey, details[sKey]); //This will set the multirow once the key is matched.
            }

 

Thanks & Regards

Swathi Padighar

1 ACCEPTED SOLUTION

Swathi P
Tera Guru

I am able to achieve it by converting all the variables into String as few the variables are in numeric values so.

View solution in original post

11 REPLIES 11

Mohith Devatte
Tera Sage
Tera Sage

hello @swathip are you getting those alerts when key is matched ?

while setting you just need to set the entire json 

LIKE BELOW 

[{"field_1_label":"field_1_value" ,"field_2_label":"field_2_value"},

{"field_1_label":"field_1_value" , "field_2_label":"field_2_value"} ]

can you tell me whats coming in alert and what value you are trying to set

if you can post the script which will be helpful to debug

I am getting alerts . but the variable set is not getting auto populated . Upon entering the values in quantity the object should be pushed into variable set .  I am not getting what s the mistake here.

html :

<td> <input type = 'text' maxlength="2" size="2" ng-model="poLine.quantity" ng-init="poLine.quantity=0" ng-change="fieldChange(poLine)" required ></td>

This is my client controller script 

 $scope.fieldChange = function(poLine) {
        var oDetails = [];
        oDetails.push(poLine);
        var details = {
            "total_rows": 1,
            "invoice_line_items": oDetails
        };
        var  three_way = $scope.page.g_form.getField("invoice_line_items");
        alert(JSON.stringify(details));   
        for (var sKey in details) {
            if (sKey == "invoice_line_items") {
              
               $scope.page.g_form.setValue(sKey, details[sKey]); /
        }

    };

hello @swathip ,

okay can you send the screenshot of your MVRS ?

may be i can tell you the json that needs to be pushed after seeing it 

are these JSON elements fields of mvrs ?

   var details = {
            "total_rows": 1,
            "invoice_line_items": oDetails
        };

TOTAL ROWS --> field one in MVRS

Invoice line items -->Second field in MVRS (assuming to be a list collector ?)

 

please post the screenshot of MVRS once

 

Sorry my miss  this is the edited script. the below is the screenshot of the variable set.

 

 $scope.fieldChange = function(poLine) {
    
        var three_way = $scope.page.g_form.getField("invoice_line_items_three_way");// variable set
      
        for (var sKey in poLine) {
            
               $scope.page.g_form.setValue(sKey, poLine[sKey]); 
            
        }

    };

find_real_file.png