Part Two: Using Javascript to identify when to send a message

November 30, 2010

Using Javascript to identify when to send a message

In part one, we learned how to create custom output messages with Javascript.  In part two, we will see how to create custom conditions that enable us to accurately determine when to send a message.

As in part one, we will incorporate a jscall into our condition field in order to be able to query fields and conditions that are not in our $L.file (current record).  Many times, we have a necessity to base our notifications on more than simply the contents of the current record.  An excellent example of this is based on whether any of the approvals for the current record have been denied.   This example is the condition we will evaluate today.

1.       Your condition will be constructed using the condition field.  Since the condition field should evaluate to either a true or a false value, this means that any call to Javascript here must return a value of true or false

2.       You’ll need to pass the current record(s) to the Javascript.

Replacing the condition:  You want to replace the argument with:

jscall(“CustomNotificationHelpers.NotifyifDenied”, $L.file, $L.file.save)

Javascript condition

Javascript condition

The ScriptLibrary Function should look something like this:

function NotifyifDenied(record, oldrecord)
{
	var fApprovalLog = new SCFile("ApprovalLog")

	var filename = system.functions.filename(record)
	var anyDenied = fApprovalLog.doSelect("file.name=""+filename+" and unique.key=""+record.number+" and current.phase=""+record.current_phase+"" and status="Denied"")

	if (anyDenied == RC_SUCCESS)
	{
		return true
	} else {
		return false
	}
}

This example showed how your notification line is no longer bound to the contents of the current record.  

The sky is the limit in your ability to finely tune and control when to notify customers for records.

This is continued in Part 3.

Comments

No Comments Yet.

Got something to say?





Spam Protection by WP-SpamFree

Contact Us

Laura Walker
Director of Business Development
Office: 701-232-5697 x27
Mobile: 701-306-7774
Email: lwalker@stratacominc.com

Client Testimonial

“As the project progressed through the various phases, StrataCom demonstrated their customer service commitment. A high level of responsiveness both in day-to-day support as well as with the deliverables assigned to them was realized. StrataCom became a true partner with us and the project team genuinely felt that our success was a priority for them. As a partner, StrataCom actively performed knowledge transfer and mentored our technical staff, accelerating our learning curve with the product.” ~Client Project Manager