session Object is not working correctly

Community Alums
Not applicable

 

var char = new GlideRecord('sn_ind_tmt_orm_order_characteristic_value');
            char.addQuery('order_line_item', current.order_line_item.sys_id.toString());

            char.query();
            while (char.next()) {
                if (char.characteristic.name.indexOf('Service Type') != -1) {
                    gs.info('Service Type:' + char.characteristic.name);
                    session.putClientData('serviceType', char.characteristic_option.option.toString());

                }



                if (char.characteristic.name.indexOf('3rd Party Equipment') != -1) {
                    gs.info('3rd Party Equipment' + char.characteristic.name);
                    session.putClientData('3rdParty', char.characteristic_option.option.toString());
                    gs.info('3rdParty:' + session.getClientData('3rdParty'));

                }

                if (char.characteristic.name.indexOf('IP Address Block') != -1) {
                    gs.info('IP Address Block' + char.characteristic.name);
                    session.putClientData('ipAddress', char.characteristic_option.option.toString());

                }
 }
			

 var circuit = new GlideRecord('x_tpm_inventory_re_inventory_request_network_circuit');
                circuit.initialize();
circuit.service_type = session.getClientData('serviceType');
                circuit.rd_party_equipment = session.getClientData('3rdParty');
                circuit.ip_address = session.getClientData('ipAddress');
   var gr = circuit.insert();

 

 
 
 Hi Team,

Above is the UI Action written which is server side. The issue is same session data is copied to all the places even though the condition is not satisfied.

 

circuit.service_type = session.getClientData('serviceType');

The above serviceType is copied to both of below:

circuit.rd_party_equipment = session.getClientData('3rdParty');
   circuit.ip_address = session.getClientData('ipAddress');
 
Kindly let me know why is this happening as the If condition is not getting passed other than Servicetype field

 

 

 

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

In your testing are you only getting the correct 3rd party... / IP Address... log or both?  Assuming you are only getting the correct one, the issue is that the old session data (from a previous test) still exists, so you either need to clear it in each if block, or use the same if conditions for the assignments in the GlideRecord.