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 TaskThe following sample code creates a custom button labeled Assign Next Step Task on the Opportunity Detail page. When the button is clicked, a function is called to open the Task Open page with appropriate values. The task can then be saved and used to follow up on the next step for the opportunity. // entry point for running custom code oraclecrmod.onReady(function() // when on the Opportunity Detail page if (oraclecrmod.ctx.object == "Opportunity" && oraclecrmod.ctx.isDetailPage()) { var Id = oraclecrmod.getField("Id").getValue(); var oppName = oraclecrmod.getField("Name").getValue(); var nextstep = oraclecrmod.getField("Next Step").getValue(); var desc = "Please follow up on the next step for this opportunity: " + nextstep; var subject = "Follow up on next step for " + oppName; date1.setDate(date1.getDate() + 2); var mm = date1.getMonth()+1; // month starts at 0 e.g. Jan = 0 var date1Formatted = mm + '/' + dd + '/' + y; window.open("/OnDemand/user/TaskNew?OMRET0=OpportunityDetail%3fOpptyDetailForm.Id%3d" + Id + "&OMCR0=" + Id + "&OCTYPE=&OMTGT=TaskEditForm&OMTHD=ActivityNewNav&OMCBO=Opportunity&TaskEditForm.Due Date=" + encodeURIComponent(date1Formatted) + "&TaskEditForm.Comment=" + encodeURIComponent(desc) + "&TaskEditForm.Description=" + encodeURIComponent(subject), "_self"); titleBar = oraclecrmod.getTitleBar("OpportunityFormTB"); button = oraclecrmod.createButton({ text: "Assign Next Step Task", // 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. | |