The undefined value has no properties. 140522

allen_pitts
Giga Expert

Hello Implementation Forum,

 

The Ops Project form is creating Ops Project Tasks and associating
the tasks correctly with the projects. Also got some of the project values
like facility and short description to write to tasks fields to eliminate duplication of input.

 

Code herewith below.

The line that begins
new_task.u_ops_project_task.start_date

is causing me some heartburn.

 

Getting error message:

Error running business rule 'Ops_project_create_runbook' on u_ops_project:OPS0000075, exception: org.mozilla.javascript.EvaluatorException:
The undefined value has no properties. (sys_script.af45d51ee4b0250027cd50546da909f6; line 😎

 

Research says that in JavaScript undefined property indicates that a variable has not been assigned a value.
So used message log to write current.u_request_date to the System log. Result:

'Log message written by OPS0000076 at 05-22-2014 for facility 2014-05-29 21:29:49'

It looks like current.u_request is getting a value.

 

Thought that maybe it is a timing issue with the data being written to the database
so tried the When on the business rule from 'before' to 'after'. No change.

 

Running out of ideas.

 

Thanks.

 

Allen Pitts
LHP Hospital System

 

++++++++++++++++++begin business rule code+++++++++++++++++

// write message to log 140520 acp (take this out after test)

var msg = "Log message written by "   + current.number + " at " + gs.now() + " for facility " + current.u_request_date;

gs.log(msg);

 

// create new task, associate with ops project, auto populate fields 140522 acp

var new_task = new GlideRecord("u_ops_project_task");

new_task.initialize();

new_task.u_ops_project_task.start_date = current.u_request_date;

new_task.u_facility = current.company;

new_task.short_description = current.short_description + " - Create Runbook";

new_task.parent = current.sys_id;

new_task.insert();

 

++++++++++++++++++end business rule code+++++++++++++++++++

1 ACCEPTED SOLUTION

new_task.u_ops_project_task.start_date = current.u_request_date;


It looks like you are dot walking here to u_ops_project_task.   Is this a valid field/variable? The rest of new_task is only updating on the first   level, ex: new_task.parent =, new_task.short_description =



Why does line 8 have an extra level/object?



Can you just do:


new_task.start_date = current.u_request_date;


?


View solution in original post

8 REPLIES 8

I've been there so many times now...


Hello Justin,


The business rule with code discussed creates an Ops Project Task
when an Ops Project is created with Project Type 'New System' and


associates the Ops Project Task with the Ops Project
new_task.parent = current.sys_id;



In previous discussions a couple of folks said that the best practice
would be workflow. The project was started using a business rule
frankly because I understand business rules and don't have any
experience with workflows. But workflows have been studied and
some grasp has been gained and the code written in the busness rule
can be used in the workflow.




The question is: How do I get the submittal Ops Project with Project Type 'New System'
to launch the work flow? And how to get a task created by the workflow









to be associated with the Ops Project that launched the workflow?



Thanks



Allen Pitts
LHP Hospital Group


Hi Allen,



You can conditionalize a workflow to run on whatever conditions you like.


Please see the attached screenshot.



Once you create a new workflow, click the gear at the top of the window, then select Properties. Set it to the ops project table where you want the workflow to run, then setup the conditions.



Once those conditions are met, the workflow will run.



Thanks,


Justin


In my attached example, whenever a record on cmdb_ci_server is assigned to me the workflow will kick off.