Calling Entity Methods in Custom Searches

From C3 Wiki

Jump to: navigation, search

[edit] Summary

When building custom searches, you have the ability to call entity methods on the fly that will return calculated data. (Note that these must be zero argument methods; in other words the yield a result without passing anything to them.) To do this, create an entity method on the return type of the custom search (ie: _Protocol). Under the properties, of the method, click the box labeled: "Display method in web site user interfaces". Once you have created and saved your method, you can edit any custom search with that return type to display the method.

[edit] Example

Example 1: Calculate the interval between dates on a Protocol. Entity method defined on _Protocol.

function calcDaysFromReceivedToApproved()
{
	try {
	var one_day = 1000*60*60*24; // number of milliseconds in a day
	var DateApproved = this.getQualifiedAttribute("customAttributes._attribute154");
	var DateReceived = this.getQualifiedAttribute("customAttributes.dateReceived");
	DateApproved = new Date(DateApproved);
	DateReceived = new Date(DateReceived);
	var intDateApproved = DateApproved.getTime();
	var intDateReceived = DateReceived.getTime();
	var intMilliInterval =  intDateApproved - intDateReceived;
	var intDayInterval = intMilliInterval / one_day
	var wholeDayInterval = parseInt(intDayInterval);
	return wholeDayInterval;
	}
	catch (e) {
		wom.log("EXCEPTION _Protocol.calcDaysFromReceivedToApproved: " + e.description);
		throw(e);
	}
}

Example 2: See Displaying Images in Custom Searches

Example 3: See Logging Page Access with Custom Searches

Example 4: See Building Entity Sets with Custom Searches


Wake Forest