Bookshelf Home | Contents | Index | PDF |
Oracle CRM On Demand JavaScript API Developer's Guide > JavaScript API Code Samples > Code Sample for a Custom Button That Creates a Child RecordThis following code sample creates a custom button labeled function createHttpRequest (httpmethod) xmlhttpRequest = new XMLHttpRequest(); if (typeof xmlhttpRequest.overrideMimeType != 'undefined') xmlhttpRequest.overrideMimeType('application/json'); oraclecrmod.onReady(function() // when on the Opportunity Detail page if(oraclecrmod.ctx.object == "Opportunity" && oraclecrmod.ctx.isDetailPage()) var id = oraclecrmod.getField("Id").getValue(); var insertPayload = "{\"Activities\":[ \ \"Activity\": \"Appointment\", \ \"Subject\": \"Opp Auto Appointment\", \ \"OpportunityId\":\"" + id + "\" \ //Calls REST API to create Task var url = "<PodURL>/OnDemand/user/Rest/026/Activities"; var req = createHttpRequest ("POST"); req.setRequestHeader("Content-Type","application/vnd.oracle.adf.resource+json"); if (req.readyState == 4 && req.status == 201) titleBar = oraclecrmod.getTitleBar("OpportunityFormTB"); button = oraclecrmod.createButton({id:"CreateTaskButton", text:"Create Task",parent:titleBar}); // associate the createTask function with the button click event |
Oracle CRM On Demand JavaScript API Developer's Guide, Release 34 | Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Legal Notices. | |