Dario_Garcia | 2021-05-11 18:05:26 UTC | #1
Hi,
I am new to genesys cloud, I was trying to use open data explorer as example and build something similar from scratch but I got errors about "TypeError", "property", "undefinded".
My environment: node version: v14.16.1 npm version: 6.14.12 using: cdr example
¿What am I missing out? ¿What is wrong?
Error: [root@LAB-NODE examples]# sh run.sh cdr loading config from ./examples/calldetailreport/config.json Initializing logger for api at level silly Initializing logger for TemplateDefinitions at level silly Initializing logger for executor at level silly debug: [TemplateDefinitions] Loading standard module "dataOperations" from dataOperations.js debug: [TemplateDefinitions] Loading standard module "datetimeOperations" from datetimeOperations.js Initializing logger for main at level silly (node:19194) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency (Use node --trace-warnings ... to show where the warning was created) verbose: [executor] Configuration successfully dereferenced verbose: [executor] Executor initialized info: [main] /runnow flag was used, commencing single execution of jobs... debug: [executor] Executing job: CDR job at Tue May 11 2021 13:56:38 GMT-0400 (Chile Standard Time) Initializing logger for job:CDR job at level silly debug: [TemplateDefinitions] Loading standard module "dataOperations" from dataOperations.js debug: [TemplateDefinitions] Loading standard module "datetimeOperations" from datetimeOperations.js debug: [TemplateDefinitions] Loading standard module "dataOperations" from dataOperations.js debug: [TemplateDefinitions] Loading standard module "datetimeOperations" from datetimeOperations.js debug: [job:CDR job] Loading module to def.cdrmodule from ./examples/calldetailreport/extensions.js verbose: [job:CDR job] Processing execution plan for CDR Configuration debug: [job:CDR job] singlecdrrequest strategy: debug: [job:CDR job] request done verbose: [job:CDR job] Executing transform: {{#def.cdrmodule.addSegmentsToParticipant(def.data.cdrrequest)}} verbose: [job:CDR job] Executing transform: {{#def.vars.conversationIds=def.cdrmodule.coalesceConversationIds(def.data.cdrrequest)}} debug: [job:CDR job] repeatcdrconversationdetailsrequest strategy: verbose: [executor] getconversations complete debug: [job:CDR job] request done verbose: [job:CDR job] Executing transform: {{#def.cdrmodule.aggregateParticipantAttributes(def.data)}} verbose: [job:CDR job] Executing transform: {{#def.cdrmodule.ensureAttributes(def.data.cdrrequest)}} verbose: [job:CDR job] Executing transform: {{#def.dataOperations.writeData(def.data, '../local/calldetailreport/data.json')}} debug: [job:CDR job] Execution plan complete verbose: [job:CDR job] Executing templates... verbose: [job:CDR job] Executing template: CDR template verbose: [executor] ./examples/calldetailreport/cdr_template.htmlLoading template from error: [job:CDR job] TypeError: Cannot read property 'length' of undefined * at CDR.countArray (/root/projects/open-data-exporter/src/examples/calldetailreport/extensions.js:23:13)* at eval (eval at <anonymous> (/root/projects/open-data-exporter/src/node_modules/dot/doT.js:83:12), <anonymous>:3:23) at /root/projects/open-data-exporter/src/nodemodules/dot/doT.js:83:49 at String.replace (<anonymous>) at resolveDefs (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:74:4) at Object.doT.template (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:95:33) at executeTemplate (/root/projects/open-data-exporter/src/executor.js:269:21) at /root/projects/open-data-exporter/src/executor.js:206:18 at /root/projects/open-data-exporter/src/nodemodules/lodash/lodash.js:4967:15 at baseForOwn (/root/projects/open-data-exporter/src/nodemodules/lodash/lodash.js:3032:24) error: [executor] TypeError: Cannot read property 'length' of undefined at CDR.countArray (/root/projects/open-data-exporter/src/examples/calldetailreport/extensions.js:23:13) at eval (eval at <anonymous> (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:83:12), <anonymous>:3:23) at /root/projects/open-data-exporter/src/nodemodules/dot/doT.js:83:49 at String.replace (<anonymous>) at resolveDefs (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:74:4) at Object.doT.template (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:95:33) at executeTemplate (/root/projects/open-data-exporter/src/executor.js:269:21) at /root/projects/open-data-exporter/src/executor.js:206:18 at /root/projects/open-data-exporter/src/nodemodules/lodash/lodash.js:4967:15 at baseForOwn (/root/projects/open-data-exporter/src/nodemodules/lodash/lodash.js:3032:24) error: [executor] TypeError: Cannot read property 'length' of undefined at CDR.countArray (/root/projects/open-data-exporter/src/examples/calldetailreport/extensions.js:23:13) at eval (eval at <anonymous> (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:83:12), <anonymous>:3:23) at /root/projects/open-data-exporter/src/nodemodules/dot/doT.js:83:49 at String.replace (<anonymous>) at resolveDefs (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:74:4) at Object.doT.template (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:95:33) at executeTemplate (/root/projects/open-data-exporter/src/executor.js:269:21) at /root/projects/open-data-exporter/src/executor.js:206:18 at /root/projects/open-data-exporter/src/nodemodules/lodash/lodash.js:4967:15 at baseForOwn (/root/projects/open-data-exporter/src/nodemodules/lodash/lodash.js:3032:24) error: [main] TypeError: Cannot read property 'length' of undefined at CDR.countArray (/root/projects/open-data-exporter/src/examples/calldetailreport/extensions.js:23:13) at eval (eval at <anonymous> (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:83:12), <anonymous>:3:23) at /root/projects/open-data-exporter/src/nodemodules/dot/doT.js:83:49 at String.replace (<anonymous>) at resolveDefs (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:74:4) at Object.doT.template (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:95:33) at executeTemplate (/root/projects/open-data-exporter/src/executor.js:269:21) at /root/projects/open-data-exporter/src/executor.js:206:18 at /root/projects/open-data-exporter/src/nodemodules/lodash/lodash.js:4967:15 at baseForOwn (/root/projects/open-data-exporter/src/node_modules/lodash/lodash.js:3032:24)
tim.smith | 2021-05-11 18:43:30 UTC | #2
DarioGarcia, post:1, topic:10883
error: [job:CDR job] TypeError: Cannot read property 'length' of undefined ** at CDR.countArray (/root/projects/open-data-exporter/src/examples/calldetail_report/extensions.js:23:13)**
This error tells us that the error is being thrown from extensions.js on line 23. Assuming you haven't modified the code, that's this line: https://github.com/MyPureCloud/open-data-exporter/blob/master/src/examples/call_detail_report/extensions.js#L23.
DarioGarcia, post:1, topic:10883
at eval (eval at (/root/projects/open-data-exporter/src/nodemodules/dot/doT.js:83:12), :3:23)
The next trace in the stack trace shows us it's coming from the dot module, which is used to compile the templates. From the context of the previous trace indicating the CDR example is being used, the CDR template is calling the above linked countArray function here: https://github.com/MyPureCloud/open-data-exporter/blob/master/src/examples/call_detail_report/cdr_template.html#L13. It's passing in def.data.cdr_request.conversations, which is what is undefined based on the error message.
I'd guess the issue is that you aren't getting any conversation data. I can't say why since I don't have access to your configuration or org data, but you can fix this by checking the var first (e.g. return arr ? arr.length : 0;) and/or investigating why your queries aren't returning conversations.
Dario_Garcia | 2021-05-12 12:58:36 UTC | #3
Hi Tim,
Thanks you for your guide. After checking the return variable, I could notice my problem was in the role assigned to the client id. After give required roles, I could get the data.
Regards
system | 2021-06-12 12:58:33 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 10883