Bookshelf Home | Contents | Index | PDF |
Oracle CRM On Demand JavaScript API Developer's Guide > JavaScript API Code Samples > Code Sample 2 for Creating a Custom Button for ValidationThe following sample code creates a custom button labeled Validate on the Opportunity Detail page. When the button is clicked, a validate function is called to validate the values of the Primary Revenue Amount field. The sample code also hides the Add button on the Contact related information applet. // entry point for running custom code oraclecrmod.onReady(function() // OPPORTUNITY VALIDATE EXAMPLE // // when on the Opportunity Detail page if(oraclecrmod.ctx.object == "Opportunity" && oraclecrmod.ctx.isDetailPage()) var revenue = oraclecrmod.getField("Primary Revenue Amount").getValue(); // convert to currency string to number var number = Number(revenue.replace(/[^0-9\.]+/g, "")); // validate custom business logic goes here based on field values retrieved titleBar = oraclecrmod.getTitleBar("OpportunityFormTB"); // create the new Validate button button = oraclecrmod.createButton({ // associate the validate function with the button click event // get the Add button and hide it oraclecrmod.getButton("BTN_TB_ContactRoleChildList_ContactRoleNewNav").hide(); |
Oracle CRM On Demand JavaScript API Developer's Guide, Release 38 | Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Legal Notices. | |