SharePoint 2013

Last modified: October 03, 2012

Applies to: apps for SharePoint | Excel Services | SharePoint Server 2013

In this article
Return Value

Gets the Ewa.BrowserUdfs Object associated with the specified Ewa.EwaControl Object.


[Ewa.EwaControl.getBrowserUdfs] returns a [Ewa.BrowserUdfs] object which represents the collection of all browser user-defined functions (UDFs) associated with a [EwaControl] instance. You use the [Ewa.BrowserUdfs] to add or remove an individual browser UDF, check to see if a specific browser UDF exists, or remove all browser UDFs from the collection.

The following code example shows how to add a browser UDF to the page. The UDF takes a quantity of items and a price, calculates the cost, and then applies a 6% discount to the cost if the quantity is 100 items or more. The code example assumes that you are working with an Excel Web Access Web Part on SharePoint Server 2013.

<script type="text/javascript">
var ewa = null;

// Add event handler for onload event.
if (window.attachEvent) {
    window.attachEvent("onload", ewaOnPageLoad);
else {
    window.addEventListener("DOMContentLoaded", ewaOnPageLoad, false);

// Add event handler for applicationReady event.
function ewaOnPageLoad() {

function onApplicationReady(result) {
    ewa = Ewa.EwaControl.getInstances().getItem(0);
    var udfs = ewa.getBrowserUdfs();

    // Add the browser UDF, "DISCOUNT" to the page
    udfs.add("DISCOUNT", DISCOUNT, "Gives company discounted price.", false, false);

// UDF that returns a discount (6%) for orders with 
// 100 or more items; otherwise it returns 0.
function DISCOUNT(quantity, price) {
    var theDiscount = 0;
    var discountCost = 0;
    var initialAmount = 0;

    if (quantity >= 100) {
        initialAmount = quantity * price;
        // Apply a 6% discount
        theDiscount = initialAmount * 0.06;
        discountCost = initialAmount - theDiscount;
    else {
        discountCost = initialAmount;
    return discountCost;