Built motion from commit 25580385.|2.6.2
[motion2.git] / server / api / intServicenowAccount / intServicenowAccount.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xbcc8=['nolimit','order','sort','where','filter','merge','VIRTUAL','includeAll','include','ServicenowAccount','rows','params','options','find','catch','create','body','destroy','getConfigurations','ServicenowConfiguration','pick','addConfiguration','findOne','AccountId','Subjects','getSubjects','channel','getDescriptions','ServicenowField','Descriptions','getFields','made_sla','hold_reason','knowledge','subcategory','incident_state','severity','caused_by','upon_reject','sys_updated_on','child_incidents','approval_history','number','resolved_by','user_input','sys_created_on','sys_domain','state','calendar_stc','closed_at','cmdb_ci','impact','active','work_notes_list','business_service','priority','time_worked','expected_start','opened_at','business_duration','reopened_time','resolved_at','caller_id','approval_set','work_notes','close_code','correlation_display','work_start','assignment_group','business_stc','additional_assignee_list','description','notify','sys_class_name','close_notes','closed_by','follow_up','parent_incident','sys_id','contact_type','reopened_by','problem_id','reassignment_count','activity_due','assigned_to','sla_due','approval','comments_and_work_notes','due_date','sys_mod_count','reopen_count','sys_tags','escalation','upon_approval','correlation_id','location','category','username','password','email','remoteUri','slice','substring','lastIndexOf','%s/api/now/doc/table/schema/','%s/api/now/table/','GET','incident?sysparm_display_value=all','result','log','incident\x20table\x20objects','remove','forEach','internalType','label','push','TCL:\x20_object','TCL:\x20exports.getEntityFields\x20->\x20_objectsCustom','concat','test','Wrong\x20credentials','statusCode','True','true','False','false','sys_choice?sysparm_query=name=incident^element=','inactive','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','fs-extra','lodash','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','error','stack','name','send','index','map','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty'];(function(_0x53eba7,_0x38744c){var _0x32491b=function(_0x61ea1d){while(--_0x61ea1d){_0x53eba7['push'](_0x53eba7['shift']());}};_0x32491b(++_0x38744c);}(_0xbcc8,0x80));var _0x8bcc=function(_0x2aee2f,_0xad9887){_0x2aee2f=_0x2aee2f-0x0;var _0x19337f=_0xbcc8[_0x2aee2f];return _0x19337f;};'use strict';var emlformat=require(_0x8bcc('0x0'));var rimraf=require(_0x8bcc('0x1'));var zipdir=require(_0x8bcc('0x2'));var jsonpatch=require(_0x8bcc('0x3'));var rp=require(_0x8bcc('0x4'));var moment=require(_0x8bcc('0x5'));var BPromise=require(_0x8bcc('0x6'));var Mustache=require(_0x8bcc('0x7'));var util=require(_0x8bcc('0x8'));var path=require(_0x8bcc('0x9'));var sox=require('sox');var csv=require(_0x8bcc('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x8bcc('0xb'));var _=require(_0x8bcc('0xc'));var squel=require(_0x8bcc('0xd'));var crypto=require(_0x8bcc('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x8bcc('0xf'));var toCsv=require(_0x8bcc('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x8bcc('0x10'));var authService=require(_0x8bcc('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x8bcc('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x8bcc('0x13'))(_0x8bcc('0x14'));var utils=require('../../config/utils');var config=require(_0x8bcc('0x15'));var licenseUtil=require(_0x8bcc('0x16'));var db=require(_0x8bcc('0x17'))['db'];var integrations=require(_0x8bcc('0x18'));function respondWithStatusCode(_0x58897d,_0x5802a9){_0x5802a9=_0x5802a9||0xcc;return function(_0x48d66a){if(_0x48d66a){return _0x58897d[_0x8bcc('0x19')](_0x5802a9);}return _0x58897d[_0x8bcc('0x1a')](_0x5802a9)[_0x8bcc('0x1b')]();};}function respondWithResult(_0x2be94e,_0x311fd4){_0x311fd4=_0x311fd4||0xc8;return function(_0x10e59f){if(_0x10e59f){return _0x2be94e[_0x8bcc('0x1a')](_0x311fd4)[_0x8bcc('0x1c')](_0x10e59f);}};}function respondWithFilteredResult(_0x44c045,_0x570746){return function(_0x185f76){if(_0x185f76){var _0x576826=typeof _0x570746['offset']===_0x8bcc('0x1d')&&typeof _0x570746[_0x8bcc('0x1e')]==='undefined';var _0x39256b=_0x185f76[_0x8bcc('0x1f')];var _0x3b1aca=_0x576826?0x0:_0x570746[_0x8bcc('0x20')];var _0x215c61=_0x576826?_0x185f76[_0x8bcc('0x1f')]:_0x570746[_0x8bcc('0x20')]+_0x570746[_0x8bcc('0x1e')];var _0x5a66ba;if(_0x215c61>=_0x39256b){_0x215c61=_0x39256b;_0x5a66ba=0xc8;}else{_0x5a66ba=0xce;}_0x44c045[_0x8bcc('0x1a')](_0x5a66ba);return _0x44c045[_0x8bcc('0x21')](_0x8bcc('0x22'),_0x3b1aca+'-'+_0x215c61+'/'+_0x39256b)[_0x8bcc('0x1c')](_0x185f76);}return null;};}function patchUpdates(_0x1391e7){return function(_0x595786){try{jsonpatch[_0x8bcc('0x23')](_0x595786,_0x1391e7,!![]);}catch(_0x100fbe){return BPromise[_0x8bcc('0x24')](_0x100fbe);}return _0x595786[_0x8bcc('0x25')]();};}function saveUpdates(_0x4faf64,_0x12fd29){return function(_0x301e23){if(_0x301e23){return _0x301e23[_0x8bcc('0x26')](_0x4faf64)['then'](function(_0x50cb0e){return _0x50cb0e;});}return null;};}function removeEntity(_0x354b85,_0x1b18a0){return function(_0x2aa0a6){if(_0x2aa0a6){return _0x2aa0a6['destroy']()[_0x8bcc('0x27')](function(){_0x354b85[_0x8bcc('0x1a')](0xcc)[_0x8bcc('0x1b')]();});}};}function handleEntityNotFound(_0x29fd49,_0x2e4212){return function(_0x311a6e){if(!_0x311a6e){_0x29fd49[_0x8bcc('0x19')](0x194);}return _0x311a6e;};}function handleError(_0x2f82e2,_0x5f5002){_0x5f5002=_0x5f5002||0x1f4;return function(_0x12c0f3){logger[_0x8bcc('0x28')](_0x12c0f3[_0x8bcc('0x29')]);if(_0x12c0f3[_0x8bcc('0x2a')]){delete _0x12c0f3[_0x8bcc('0x2a')];}_0x2f82e2['status'](_0x5f5002)[_0x8bcc('0x2b')](_0x12c0f3);};}exports[_0x8bcc('0x2c')]=function(_0x4f545d,_0xb78036){var _0x413ff0={},_0x3ecca0={},_0x4cb29a={'count':0x0,'rows':[]};var _0x1578c8=_[_0x8bcc('0x2d')](db['ServicenowAccount'][_0x8bcc('0x2e')],function(_0x19c6e7){return{'name':_0x19c6e7['fieldName'],'type':_0x19c6e7[_0x8bcc('0x2f')][_0x8bcc('0x30')]};});_0x3ecca0[_0x8bcc('0x31')]=_['map'](_0x1578c8,_0x8bcc('0x2a'));_0x3ecca0[_0x8bcc('0x32')]=_[_0x8bcc('0x33')](_0x4f545d[_0x8bcc('0x32')]);_0x3ecca0[_0x8bcc('0x34')]=_[_0x8bcc('0x35')](_0x3ecca0[_0x8bcc('0x31')],_0x3ecca0[_0x8bcc('0x32')]);_0x413ff0[_0x8bcc('0x36')]=_[_0x8bcc('0x35')](_0x3ecca0['model'],qs[_0x8bcc('0x37')](_0x4f545d[_0x8bcc('0x32')]['fields']));_0x413ff0[_0x8bcc('0x36')]=_0x413ff0[_0x8bcc('0x36')][_0x8bcc('0x38')]?_0x413ff0[_0x8bcc('0x36')]:_0x3ecca0[_0x8bcc('0x31')];if(!_0x4f545d[_0x8bcc('0x32')][_0x8bcc('0x39')](_0x8bcc('0x3a'))){_0x413ff0[_0x8bcc('0x1e')]=qs[_0x8bcc('0x1e')](_0x4f545d[_0x8bcc('0x32')]['limit']);_0x413ff0[_0x8bcc('0x20')]=qs[_0x8bcc('0x20')](_0x4f545d[_0x8bcc('0x32')][_0x8bcc('0x20')]);}_0x413ff0[_0x8bcc('0x3b')]=qs[_0x8bcc('0x3c')](_0x4f545d[_0x8bcc('0x32')][_0x8bcc('0x3c')]);_0x413ff0[_0x8bcc('0x3d')]=qs['filters'](_['pick'](_0x4f545d[_0x8bcc('0x32')],_0x3ecca0[_0x8bcc('0x34')]),_0x1578c8);if(_0x4f545d[_0x8bcc('0x32')][_0x8bcc('0x3e')]){_0x413ff0['where']=_[_0x8bcc('0x3f')](_0x413ff0[_0x8bcc('0x3d')],{'$or':_[_0x8bcc('0x2d')](_0x1578c8,function(_0x2b96e8){if(_0x2b96e8[_0x8bcc('0x2f')]!==_0x8bcc('0x40')){var _0x1a9ec5={};_0x1a9ec5[_0x2b96e8[_0x8bcc('0x2a')]]={'$like':'%'+_0x4f545d[_0x8bcc('0x32')][_0x8bcc('0x3e')]+'%'};return _0x1a9ec5;}})});}_0x413ff0=_[_0x8bcc('0x3f')]({},_0x413ff0,_0x4f545d['options']);var _0x141592={'where':_0x413ff0[_0x8bcc('0x3d')]};return db['ServicenowAccount'][_0x8bcc('0x1f')](_0x141592)[_0x8bcc('0x27')](function(_0x250b98){_0x4cb29a[_0x8bcc('0x1f')]=_0x250b98;if(_0x4f545d[_0x8bcc('0x32')][_0x8bcc('0x41')]){_0x413ff0[_0x8bcc('0x42')]=[{'all':!![]}];}return db[_0x8bcc('0x43')]['findAll'](_0x413ff0);})[_0x8bcc('0x27')](function(_0x2feb26){_0x4cb29a[_0x8bcc('0x44')]=_0x2feb26;return _0x4cb29a;})[_0x8bcc('0x27')](respondWithFilteredResult(_0xb78036,_0x413ff0))['catch'](handleError(_0xb78036,null));};exports['show']=function(_0x4fb205,_0x1cb9d8){var _0xb830ad={'raw':![],'where':{'id':_0x4fb205[_0x8bcc('0x45')]['id']}},_0x2ea673={};_0x2ea673[_0x8bcc('0x31')]=_[_0x8bcc('0x33')](db[_0x8bcc('0x43')][_0x8bcc('0x2e')]);_0x2ea673['query']=_[_0x8bcc('0x33')](_0x4fb205['query']);_0x2ea673[_0x8bcc('0x34')]=_[_0x8bcc('0x35')](_0x2ea673[_0x8bcc('0x31')],_0x2ea673[_0x8bcc('0x32')]);_0xb830ad['attributes']=_[_0x8bcc('0x35')](_0x2ea673[_0x8bcc('0x31')],qs[_0x8bcc('0x37')](_0x4fb205[_0x8bcc('0x32')]['fields']));_0xb830ad[_0x8bcc('0x36')]=_0xb830ad[_0x8bcc('0x36')]['length']?_0xb830ad[_0x8bcc('0x36')]:_0x2ea673['model'];if(_0x4fb205[_0x8bcc('0x32')][_0x8bcc('0x41')]){_0xb830ad[_0x8bcc('0x42')]=[{'all':!![]}];}_0xb830ad=_['merge']({},_0xb830ad,_0x4fb205[_0x8bcc('0x46')]);return db[_0x8bcc('0x43')][_0x8bcc('0x47')](_0xb830ad)[_0x8bcc('0x27')](handleEntityNotFound(_0x1cb9d8,null))[_0x8bcc('0x27')](respondWithResult(_0x1cb9d8,null))[_0x8bcc('0x48')](handleError(_0x1cb9d8,null));};exports[_0x8bcc('0x49')]=function(_0x16876a,_0x4b6520){return db[_0x8bcc('0x43')][_0x8bcc('0x49')](_0x16876a[_0x8bcc('0x4a')],{})['then'](respondWithResult(_0x4b6520,0xc9))['catch'](handleError(_0x4b6520,null));};exports[_0x8bcc('0x26')]=function(_0x146628,_0x40cf60){if(_0x146628[_0x8bcc('0x4a')]['id']){delete _0x146628[_0x8bcc('0x4a')]['id'];}return db[_0x8bcc('0x43')][_0x8bcc('0x47')]({'where':{'id':_0x146628[_0x8bcc('0x45')]['id']}})[_0x8bcc('0x27')](handleEntityNotFound(_0x40cf60,null))[_0x8bcc('0x27')](saveUpdates(_0x146628[_0x8bcc('0x4a')],null))['then'](respondWithResult(_0x40cf60,null))[_0x8bcc('0x48')](handleError(_0x40cf60,null));};exports[_0x8bcc('0x4b')]=function(_0x437600,_0x27f0ec){return db['ServicenowAccount'][_0x8bcc('0x47')]({'where':{'id':_0x437600[_0x8bcc('0x45')]['id']}})['then'](handleEntityNotFound(_0x27f0ec,null))['then'](removeEntity(_0x27f0ec,null))[_0x8bcc('0x48')](handleError(_0x27f0ec,null));};exports[_0x8bcc('0x4c')]=function(_0xb091,_0xeab1ac,_0xca6be6){var _0x5c5351={};var _0x20e11f={};var _0x3ba2f2;var _0x170c4a;return db[_0x8bcc('0x43')]['findOne']({'where':{'id':_0xb091[_0x8bcc('0x45')]['id']}})[_0x8bcc('0x27')](handleEntityNotFound(_0xeab1ac,null))[_0x8bcc('0x27')](function(_0x24aabf){if(_0x24aabf){_0x3ba2f2=_0x24aabf;_0x20e11f[_0x8bcc('0x31')]=_[_0x8bcc('0x33')](db[_0x8bcc('0x4d')][_0x8bcc('0x2e')]);_0x20e11f[_0x8bcc('0x32')]=_[_0x8bcc('0x33')](_0xb091[_0x8bcc('0x32')]);_0x20e11f[_0x8bcc('0x34')]=_[_0x8bcc('0x35')](_0x20e11f['model'],_0x20e11f[_0x8bcc('0x32')]);_0x5c5351[_0x8bcc('0x36')]=_[_0x8bcc('0x35')](_0x20e11f[_0x8bcc('0x31')],qs[_0x8bcc('0x37')](_0xb091[_0x8bcc('0x32')][_0x8bcc('0x37')]));_0x5c5351[_0x8bcc('0x36')]=_0x5c5351['attributes'][_0x8bcc('0x38')]?_0x5c5351['attributes']:_0x20e11f[_0x8bcc('0x31')];_0x5c5351[_0x8bcc('0x3b')]=qs[_0x8bcc('0x3c')](_0xb091[_0x8bcc('0x32')]['sort']);_0x5c5351['where']=qs[_0x8bcc('0x34')](_[_0x8bcc('0x4e')](_0xb091[_0x8bcc('0x32')],_0x20e11f['filters']));if(_0xb091[_0x8bcc('0x32')]['filter']){_0x5c5351['where']=_[_0x8bcc('0x3f')](_0x5c5351['where'],{'$or':_[_0x8bcc('0x2d')](_0x5c5351[_0x8bcc('0x36')],function(_0x58505c){var _0x11fd17={};_0x11fd17[_0x58505c]={'$like':'%'+_0xb091['query'][_0x8bcc('0x3e')]+'%'};return _0x11fd17;})});}_0x5c5351=_[_0x8bcc('0x3f')]({},_0x5c5351,_0xb091[_0x8bcc('0x46')]);return _0x3ba2f2[_0x8bcc('0x4c')](_0x5c5351);}})['then'](function(_0x54a168){if(_0x54a168){_0x170c4a=_0x54a168['length'];if(!_0xb091[_0x8bcc('0x32')]['hasOwnProperty'](_0x8bcc('0x3a'))){_0x5c5351[_0x8bcc('0x1e')]=qs[_0x8bcc('0x1e')](_0xb091['query'][_0x8bcc('0x1e')]);_0x5c5351[_0x8bcc('0x20')]=qs[_0x8bcc('0x20')](_0xb091[_0x8bcc('0x32')][_0x8bcc('0x20')]);}return _0x3ba2f2[_0x8bcc('0x4c')](_0x5c5351);}})[_0x8bcc('0x27')](function(_0x808b17){if(_0x808b17){return _0x808b17?{'count':_0x170c4a,'rows':_0x808b17}:null;}})[_0x8bcc('0x27')](respondWithResult(_0xeab1ac,null))[_0x8bcc('0x48')](handleError(_0xeab1ac,null));};exports[_0x8bcc('0x4f')]=function(_0x522746,_0x3452dd,_0x4f3c9e){if(_0x522746[_0x8bcc('0x4a')]['id']){delete _0x522746[_0x8bcc('0x4a')]['id'];}return db[_0x8bcc('0x43')][_0x8bcc('0x50')]({'where':{'id':_0x522746[_0x8bcc('0x45')]['id']}})[_0x8bcc('0x27')](handleEntityNotFound(_0x3452dd,null))[_0x8bcc('0x27')](function(_0x4f0792){if(_0x4f0792){_0x522746['body'][_0x8bcc('0x51')]=_0x4f0792['id'];_0x522746['body'][_0x8bcc('0x52')]=integrations[_0x8bcc('0x53')](_0x522746['body'][_0x8bcc('0x54')],_0x522746[_0x8bcc('0x4a')][_0x8bcc('0x2f')]);_0x522746[_0x8bcc('0x4a')]['Descriptions']=integrations[_0x8bcc('0x55')](_0x522746['body']['channel'],_0x522746['body'][_0x8bcc('0x2f')]);return db[_0x8bcc('0x4d')][_0x8bcc('0x49')](_0x522746['body'],{'include':[{'model':db[_0x8bcc('0x56')],'as':_0x8bcc('0x52')},{'model':db['ServicenowField'],'as':_0x8bcc('0x57')}]});}return null;})['then'](respondWithResult(_0x3452dd,null))[_0x8bcc('0x48')](handleError(_0x3452dd,null));};exports[_0x8bcc('0x58')]=function(_0x221f7c,_0x4aeb79,_0x550bf2){var _0x35d5d5=[_0x8bcc('0x59'),_0x8bcc('0x5a'),_0x8bcc('0x5b'),_0x8bcc('0x5c'),'close_code','notify',_0x8bcc('0x5d'),_0x8bcc('0x5e'),'category'];var _0xe0e396=['parent',_0x8bcc('0x59'),_0x8bcc('0x5f'),'watch_list',_0x8bcc('0x60'),_0x8bcc('0x61'),_0x8bcc('0x62'),_0x8bcc('0x5a'),_0x8bcc('0x63'),_0x8bcc('0x64'),_0x8bcc('0x65'),'sys_updated_by','opened_by',_0x8bcc('0x66'),_0x8bcc('0x67'),_0x8bcc('0x68'),_0x8bcc('0x69'),'sys_created_by','knowledge',_0x8bcc('0x3b'),_0x8bcc('0x6a'),_0x8bcc('0x6b'),_0x8bcc('0x6c'),'delivery_plan',_0x8bcc('0x6d'),_0x8bcc('0x6e'),_0x8bcc('0x6f'),_0x8bcc('0x70'),_0x8bcc('0x71'),'sys_domain_path','rfc',_0x8bcc('0x72'),_0x8bcc('0x73'),_0x8bcc('0x74'),_0x8bcc('0x75'),'group_list','work_end',_0x8bcc('0x76'),_0x8bcc('0x77'),_0x8bcc('0x78'),_0x8bcc('0x79'),_0x8bcc('0x5c'),_0x8bcc('0x7a'),'short_description',_0x8bcc('0x7b'),_0x8bcc('0x7c'),'delivery_task',_0x8bcc('0x7d'),_0x8bcc('0x7e'),_0x8bcc('0x7f'),_0x8bcc('0x80'),_0x8bcc('0x81'),'calendar_duration',_0x8bcc('0x82'),_0x8bcc('0x83'),_0x8bcc('0x84'),_0x8bcc('0x85'),_0x8bcc('0x86'),_0x8bcc('0x87'),_0x8bcc('0x88'),_0x8bcc('0x89'),_0x8bcc('0x8a'),_0x8bcc('0x5d'),'urgency',_0x8bcc('0x8b'),'company',_0x8bcc('0x8c'),_0x8bcc('0x8d'),_0x8bcc('0x8e'),'severity','comments',_0x8bcc('0x8f'),_0x8bcc('0x90'),_0x8bcc('0x91'),_0x8bcc('0x92'),_0x8bcc('0x93'),_0x8bcc('0x94'),_0x8bcc('0x95'),_0x8bcc('0x96'),_0x8bcc('0x97'),_0x8bcc('0x98'),_0x8bcc('0x99'),_0x8bcc('0x9a')];var _0x274423='';var _0x1350a2='';var _0x4b78ab=[];var _0x1c2f20='';var _0x3430b5='';var _0x2f0f8f=[];var _0x324cbe='';var _0x6939ee='';var _0x361816={};var _0x693701='';return db['ServicenowAccount'][_0x8bcc('0x50')]({'where':{'id':_0x221f7c['params']['id']},'attributes':['id',_0x8bcc('0x9b'),_0x8bcc('0x9c'),_0x8bcc('0x9d'),_0x8bcc('0x9e'),'serverUrl']})[_0x8bcc('0x27')](handleEntityNotFound(_0x4aeb79,null))['then'](function(_0x4f2c19){if(_0x4f2c19){_0x693701=_0x4f2c19[_0x8bcc('0x9e')];var _0x423cd9=_0x693701[_0x8bcc('0x9f')](-0x1);if(_0x423cd9==='/'){_0x693701=_0x693701[_0x8bcc('0xa0')](0x0,_0x693701[_0x8bcc('0xa1')](_0x423cd9));}_0x6939ee=util['format'](_0x8bcc('0xa2'),_0x693701);_0x324cbe=util['format'](_0x8bcc('0xa3'),_0x693701);_0x361816={'user':_0x4f2c19[_0x8bcc('0x9b')],'pass':_0x4f2c19[_0x8bcc('0x9c')]};var _0x244236={'method':_0x8bcc('0xa4'),'uri':_0x6939ee+_0x8bcc('0xa5'),'auth':_0x361816,'json':!![]};return rp(_0x244236);}})[_0x8bcc('0x27')](function(_0x4b66da){if(_0x4b66da[_0x8bcc('0xa6')][_0x8bcc('0x38')]>0x0){_0x274423=_0x4b66da[_0x8bcc('0xa6')];}console[_0x8bcc('0xa7')](_0x8bcc('0xa8'),_0x274423);_0x2f0f8f=[];_0x1350a2=Object['assign']([],_0x274423);_[_0x8bcc('0xa9')](_0x1350a2,function(_0x168c70){return!_0x35d5d5['includes'](_0x168c70[_0x8bcc('0x2a')]);});_0x1350a2[_0x8bcc('0xaa')](function(_0x169f01){var _0x2b8c1b=createFieldObject(_0x324cbe,_0x361816,_0x169f01[_0x8bcc('0xab')],_0x169f01['name'],_0x169f01[_0x8bcc('0xac')],![]);_0x2f0f8f[_0x8bcc('0xad')](_0x2b8c1b);});return Promise['all'](_0x2f0f8f);})[_0x8bcc('0x27')](function(_0xb4afeb){_0x4b78ab=_0xb4afeb;_0x1c2f20=Object['assign']([],_0x274423);console[_0x8bcc('0xa7')](_0x8bcc('0xae'),_0x274423);_[_0x8bcc('0xa9')](_0x1c2f20,function(_0x5ab06b){return _0xe0e396['includes'](_0x5ab06b['name']);});console[_0x8bcc('0xa7')](_0x8bcc('0xaf'),_0x1c2f20);_0x2f0f8f=[];_0x1c2f20[_0x8bcc('0xaa')](function(_0x5774ea){var _0x5553f3=createFieldObject(_0x324cbe,_0x361816,_0x5774ea[_0x8bcc('0xab')],_0x5774ea['name'],_0x5774ea[_0x8bcc('0xac')],!![]);_0x2f0f8f['push'](_0x5553f3);});return Promise['all'](_0x2f0f8f);})[_0x8bcc('0x27')](function(_0x162cd0){_0x3430b5=_0x162cd0;var _0xf9a250=_0x4b78ab[_0x8bcc('0xb0')](_0x3430b5);return{'count':_0xf9a250[_0x8bcc('0x38')],'rows':_0xf9a250};})[_0x8bcc('0x27')](respondWithResult(_0x4aeb79,null))[_0x8bcc('0x48')](function(_0x2048fc){console[_0x8bcc('0xa7')]('ServiceNow\x20error:\x20'+_0x2048fc);var _0x4696cf=_0x221f7c[_0x8bcc('0x32')][_0x8bcc('0xb1')]?0x1f4:_0x2048fc['statusCode']||0x1f4;logger[_0x8bcc('0x28')](_0x2048fc['stack']);delete _0x2048fc['name'];if(_0x4696cf===0x191){_0x4696cf=0x190;}_0x4aeb79[_0x8bcc('0x1a')](_0x4696cf)[_0x8bcc('0x2b')](_0x221f7c[_0x8bcc('0x32')]['test']?{'message':_0x8bcc('0xb2'),'statusCode':_0x2048fc[_0x8bcc('0xb3')]}:_0x2048fc);});};function createFieldObject(_0x578ff0,_0x6c25f8,_0x1fd42e,_0x1e0484,_0x5ae40a,_0xac8153){return new Promise(function(_0x465c00,_0x5b0a95){var _0x372df7={'id':_0x1e0484,'name':_0x5ae40a,'custom':_0xac8153};if(_0x1fd42e==='boolean'){_0x372df7[_0x8bcc('0x46')]=[{'name':_0x8bcc('0xb4'),'value':_0x8bcc('0xb5')},{'name':_0x8bcc('0xb6'),'value':_0x8bcc('0xb7')}];_0x465c00(_0x372df7);}else{var _0x52b254={'method':_0x8bcc('0xa4'),'uri':_0x578ff0+_0x8bcc('0xb8')+_0x1e0484,'auth':_0x6c25f8,'json':!![]};return rp(_0x52b254)[_0x8bcc('0x27')](function(_0xb6ed1b){var _0x2c401d=[];if(_0xb6ed1b[_0x8bcc('0xa6')][_0x8bcc('0x38')]>0x0){_0xb6ed1b[_0x8bcc('0xa6')][_0x8bcc('0xaa')](function(_0x5f2fc){if(_0x5f2fc[_0x8bcc('0xb9')]===_0x8bcc('0xb7')){var _0x2b4473={'name':_0x5f2fc[_0x8bcc('0xac')],'value':_0x5f2fc['value']};_0x2c401d[_0x8bcc('0xad')](_0x2b4473);}});}_0x372df7[_0x8bcc('0x46')]=_0x2c401d;if(_0x372df7[_0x8bcc('0x46')][_0x8bcc('0x38')]>0x0){_0x465c00(_0x372df7);}else{if(_0xac8153==![]){_0x465c00();}else{_0x465c00(_0x372df7);}}});}});}