cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a selected rows from one sessioninfotable to other sessioninfotable

Newbie

Adding a selected rows from one sessioninfotable to other sessioninfotable

Hello,

We are trying to add selected rows of one sessioninfotable(inftbl) into another sessioninfotable(inftbl2) - Please refer "SNIPPET1"

But "SNIPPET2" returns null.

Either of below code is wrong-

1. inftbl2.AddRow(newEntry);

2. SNIPPET2

Please guide us

--------------------------------------------------------------------------------------------------------------------------------------------

for (var i=0;i<inftbl.getRowCount();i++){

  

//////////add newEntry from inftbl into inftbl2 - SNIPPET1

        table1Entry = inftbl.getRow(i);

        // QMS-.wt.part.WTPartMaster.Mod entry object

        var newEntry = new Object();

        newEntry['thePersistInfo--updateStamp'] = table1Entry['thePersistInfo--updateStamp'];

        newEntry['latestiteration_obid'] = table1Entry['latestiteration_obid'];

        newEntry['searchType'] = table1Entry['searchType'];

        newEntry['show'] = table1Entry['show'];

        newEntry['state--state'] = table1Entry['state--state'];

        newEntry['thePersistInfo--markForDelete'] = table1Entry['thePersistInfo--markForDelete'];

        newEntry['Quantity'] = table1Entry['Quantity'];

        newEntry['check'] = table1Entry['check'];

        newEntry['type'] = table1Entry['type'];

        newEntry['version'] = table1Entry['version'];

        newEntry['aff_unit'] = table1Entry['aff_unit'];

        newEntry['versionInfo--identifier--versionId'] = table1Entry['versionInfo--identifier--versionId'];

        newEntry['number'] = table1Entry['number'];

        newEntry['Translation_Name'] = table1Entry['Translation_Name'];

        newEntry['thePersistInfo--updateCount'] = table1Entry['thePersistInfo--updateCount'];

        newEntry['thePersistInfo--modifyStamp'] = table1Entry['thePersistInfo--modifyStamp'];

        newEntry['name'] = table1Entry['name'];

        newEntry['thePersistInfo--createStamp'] = table1Entry['thePersistInfo--createStamp'];

        newEntry['state'] = table1Entry['state'];

        newEntry['obid'] = table1Entry['obid'];

      

        inftbl2.AddRow(newEntry);

      

        //////////check if newEntry is added into inftbl2 - SNIPPET2

          obj={};

          obj["obid"] = table1Entry.obid;

          logger.info(" recent added row in inftbl2 ---" +inftbl2.Find(obj));

}

Thanks in Advance.

Tags (1)
3 REPLIES 3

Re: Adding a selected rows from one sessioninfotable to other sessioninfotable

Session variables work a bit differently.  You have to construct your infotable and then use the following code to set the session variable:

var params = {

            name: "inftbl2" /* The string name of the session parameter you want to set */,

            value: <yourInfotable variable name> /* the infotable you've constructed with the data you want to assign to your session infotable variable */

};

  

Resources["CurrentSessionInfo"].SetGlobalSessionInfoTableValue(params);



So first create your infotable:


var params = {

infoTableName : "myInfoTable",

dataShapeName : "<somedatashape>"

};

var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

var newEntry=newObject();

new.Entry.propA="asdfsd";

newEntry.propB="asfsdf";

myInfoTable.AddRow(newEntry);

Then set the session property value:

var params = {

            name: "myInfoTable" /* The string name of the session parameter you want to set */,

            value: inftbl2 /* the infotable you've constructed with the data you want to assign to your session infotable variable */

};

Resources["CurrentSessionInfo"].SetGlobalSessionInfoTableValue(params);

Highlighted

Re: Adding a selected rows from one sessioninfotable to other sessioninfotable

Thanks Wayne.

Setting session property value didn't help us. Let me paste complete code here. Please advise.

var sessg = Resources["CurrentSessionInfo"].GetGlobalSessionValues(); // Getting Session varaibles

// GET inftbl FROM SESSION

var params = {

infoTableName : "InfoTable",

dataShapeName : "QMS-.wt.part.WTPartMaster.Mod"

};

var inftbl = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

inftbl = sessg.inftbl1;

// GET inftbl2FromSession FROM SESSION

var params = {

infoTableName : "InfoTable",

dataShapeName : "QMS-.wt.part.WTPartMaster.Mod"

};

var inftbl2FromSession = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

inftbl2FromSession = sessg.inftbl2;

// Move from inftbl to inftbl2FromSession

var table1Entry;

for (var i=0;i<inftbl.getRowCount();i++){

    table1Entry = inftbl.getRow(i);

    if ((table1Entry.check) && !(me.DetIfEntryExistsInInfoTbl({colname: 'obid',val: table1Entry.obid}))){

        table1Entry.check = false;

       

        var newEntry = new Object();

        newEntry['thePersistInfo--updateStamp'] = table1Entry['thePersistInfo--updateStamp'];

        newEntry['latestiteration_obid'] = table1Entry['latestiteration_obid'];

        newEntry['searchType'] = table1Entry['searchType'];

        newEntry['show'] = table1Entry['show'];

        newEntry['state--state'] = table1Entry['state--state'];

        newEntry['thePersistInfo--markForDelete'] = table1Entry['thePersistInfo--markForDelete'];

        newEntry['Quantity'] = table1Entry['Quantity'];

        newEntry['check'] = table1Entry['check'];

        newEntry['type'] = table1Entry['type'];

        newEntry['version'] = table1Entry['version'];

        newEntry['aff_unit'] = table1Entry['aff_unit'];

        newEntry['versionInfo--identifier--versionId'] = table1Entry['versionInfo--identifier--versionId'];

        newEntry['number'] = table1Entry['number'];

        newEntry['Translation_Name'] = table1Entry['Translation_Name'];

        newEntry['thePersistInfo--updateCount'] = table1Entry['thePersistInfo--updateCount'];

        newEntry['thePersistInfo--modifyStamp'] = table1Entry['thePersistInfo--modifyStamp'];

        newEntry['name'] = table1Entry['name'];

        newEntry['thePersistInfo--createStamp'] = table1Entry['thePersistInfo--createStamp'];

        newEntry['state'] = table1Entry['state'];

        newEntry['obid'] = table1Entry['obid'];

       

        inftbl2FromSession.AddRow(newEntry);

        // Checking whether entry added from inftbl to inftbl2FromSession

        obj={};

obj["obid"] = table1Entry.obid;

        logger.info(" recent added row in inftbl2FromSession ---" +inftbl2FromSession.Find(obj));

    }

}

//AS SUGGESTED BY WAYNE

// Setting inftbl2FromSession to session variable inftbl2

var params = {

name: 'inftbl2',

value: inftbl2FromSession

};

Resources["CurrentSessionInfo"].SetGlobalSessionInfoTableValue(params);

Re: Adding a selected rows from one sessioninfotable to other sessioninfotable

The main issue I see is that the mapping between the infotable you're trying to create and what's stored in the session may not be exactly the same.  Hard to say since I don't know what your session variable actually looks like.  With that being said, if you know for a fact that your inftbl2 variable has data then you can simply do:

var sessionInftbl2=Resources["CurrentSessionInfo"].GetGlobalSessionValues().inftbl2;

This guarantees that there are no mapping issues between your infotables and sessionInftbl2 will populate with whatever data is stored in your session variable.  If there is no data in your inftbl2 variable, then when you create your infotable, do not set it equal to the inftbl2 variable.  Simply build out your IT and then set it using the SetGlobalSessionInfoTableValue service like you are currently doing.