trying to Cart API for record producer but showing error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 10:43 AM
hi this is my script
here I am writing BR on attachment table when the Incident is added with an particular sheet. Once the sheet is added I want to create an Incident with the record producer.
My script is not working for th record producer but working for any catalog item.
please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 12:10 PM
Hi @Rahul Raja Sami,
Can you please elaborate on what sort of issue you are getting? Please check the system log as well.
For an Incident, there could be mandatory fields that must be populated which your script may not be doing.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 12:34 AM
Hi James
this is the error on logs
Root cause of JavaScriptException: java.lang.NullPointerException
: java.lang.NullPointerException: com.glideapp.servicecatalog.RequestNew.createVariablePool(RequestNew.java:754)
com.glideapp.servicecatalog.RequestNew.createRequestItem(RequestNew.java:605)
com.glideapp.servicecatalog.RequestNew.processOneCartItem(RequestNew.java:1025)
com.glideapp.servicecatalog.RequestNew.copyCartForRequest(RequestNew.java:335)
com.glideapp.servicecatalog.RequestNew.copyCart(RequestNew.java:289)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:566)
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:138)
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:300)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2652)
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1518)
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:830)
org.mozilla.javascript.InterpretedFunction.lambda$call$0(InterpretedFunction.java:160)
com.glide.caller.gen.sys_script_include_340b86140a0a0aa700d9f0aea1fb399a_script.call(Unknown Source)
com.glide.script.ScriptCaller.call(ScriptCaller.java:22)
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:159)
org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2734)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2657)
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1518)
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:830)
org.mozilla.javascript.InterpretedFunction.lambda$call$0(InterpretedFunction.java:160)
com.glide.caller.gen.sys_script_078696f21b148ad05cf40f6cdc4bcbae_script.call(Unknown Source)
com.glide.script.ScriptCaller.call(ScriptCaller.java:22)
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:159)
org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2734)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2657)
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1518)
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:830)
org.mozilla.javascript.InterpretedFunction.lambda$exec$1(InterpretedFunction.java:176)
com.glide.caller.gen.sys_script_078696f21b148ad05cf40f6cdc4bcbae_script.call(Unknown Source)
com.glide.script.ScriptCaller.call(ScriptCaller.java:22)
org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)
com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:389)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:199)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:131)
com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:363)
com.glide.script.BusinessRule.runScript(BusinessRule.java:468)
com.glide.script.BusinessRule.runSyncBusinessRule(BusinessRule.java:344)
com.glide.script.BusinessRule.runBusinessRule(BusinessRule.java:227)
com.glide.script.BusinessRule.run(BusinessRule.java:196)
com.glide.script.GlideRecordBusinessRules.run(GlideRecordBusinessRules.java:264)
com.glide.script.GlideRecord.runScripts(GlideRecord.java:1448)
com.glide.script.GlideRecord.runScriptsAndEngines(GlideRecord.java:1386)
com.glide.script.GlideRecord.postChange(GlideRecord.java:5370)
com.glide.script.GlideRecord.postUpdate(GlideRecord.java:5338)
com.glide.script.GlideRecord.updateWithoutResettingOperation(GlideRecord.java:4866)
com.glide.script.GlideRecord.update(GlideRecord.java:4733)
com.glide.script.GlideRecord.update(GlideRecord.java:4652)
com.glide.ui.SysAttachment.setState(SysAttachment.java:3976)
com.glide.snap.AntiVirusOnDemandAdvisor.getAvailability(AntiVirusOnDemandAdvisor.java:115)
com.glide.snap.AntiVirusOnDemandAdvisor.jsStaticFunction_getAvailabilityAfterUpload(AntiVirusOnDemandAdvisor.java:101)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:566)
org.mozilla.javascript.MemberBox.invoke(MemberBox.java:138)
org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:677)
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:614)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2649)
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1518)
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:830)
org.mozilla.javascript.InterpretedFunction.lambda$call$0(InterpretedFunction.java:160)
com.glide.caller.gen.sys_trigger_e20013761b90cad05cf40f6cdc4bcbb1.call(Unknown Source)
com.glide.script.ScriptCaller.call(ScriptCaller.java:22)
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:159)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:597)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3573)
org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:172)
com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:389)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:199)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:131)
com.glide.script.Evaluator.evaluatePossiblePrefixedString(Evaluator.java:217)
com.glide.job.RunScriptJob.evaluateScript(RunScriptJob.java:182)
com.glide.job.RunScriptJob.evaluateScript(RunScriptJob.java:157)
com.glide.job.RunScriptJob.execute(RunScriptJob.java:88)
com.glide.schedule.JobExecutor.lambda$executeJob$0(JobExecutor.java:169)
com.glide.schedule.JobExecutor.executeJob(JobExecutor.java:172)
com.glide.schedule.JobExecutor.execute(JobExecutor.java:155)
com.glide.schedule.JobExecutor.execute(JobExecutor.java:149)
com.glide.schedule_v2.SchedulerWorkerThread.executeJob(SchedulerWorkerThread.java:449)
com.glide.schedule_v2.SchedulerWorkerThread.lambda$process$1(SchedulerWorkerThread.java:318)
com.glide.worker.TransactionalWorkerThread.executeInTransaction(TransactionalWorkerThread.java:35)
com.glide.schedule_v2.SchedulerWorkerThread.process(SchedulerWorkerThread.java:318)
com.glide.schedule_v2.SchedulerWorkerThread.run(SchedulerWorkerThread.java:118)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 01:27 AM
Hi,
I think your approach is a little bit "off".
This will generate a Request (RITM with the record producer inside) - not generating an incident.
I just tested this:
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId); //calling the cart API
var item = cart.addItem('3f1dd0320a0a0b99000a53f7604a2ef9'); //sysid of the record producer
cart.setVariable(item, 'comments', 'test description');
var rc = cart.placeOrder();
You can make an incident from GlideRecord and parse the information from your excel directly into the incident record. - Theres no need of doing it through a record producer because the record producer just generates an incident anyway.