Row Action to pop Dialog Box/Create New Record

  • 1
  • Question
  • Updated 3 years ago
We currently have a button on our Case object that pops a dialog box asking for the agent to enter a number of minutes. They do so and click ok and that fires off the creation of a task with all the other required field values preset and adds the minutes they entered into the minutes field on the task.
That process works great. I'm now looking to recreate this by adding a row action to a skuid page that does the same thing for the row the action is clicked for. So it would create a task related to the case in that row.

Below is the code used for the button on our case page layouts. Any suggestions on making an in-line snippet that will perform this same task of opening a dialog box, asking for minutes, and then creating the task related to the case for the row the action was on?

Thank you in advance for any advice!

var minutes = prompt("Enter Minutes", ""); if(minutes != null) try{ var taskToCreate = new sforce.SObject("Task"); 
taskToCreate.OwnerId = "{!$User.Id}"; 
taskToCreate.WhatId = "{!Case.Id}"; 
taskToCreate.Subject = "Time Logged - Support";
taskToCreate.ActivityDate = new Date();
taskToCreate.Duration_Minutes__c = minutes;
taskToCreate.CSC_Event_Type__c = "Support"; 
taskToCreate.Priority = "Normal"; 
taskToCreate.Status = "Completed"; 
result = sforce.connection.create([taskToCreate]); 
if(result[0].success == "true"){ 
location.reload() ; } else{ alert( "An Error has Occurred. Error: \r\n" + result[0].errors.message ); } } catch(e){ alert( "An Un-expected Error has Occurred. Error: \r\n" + e ); }
Photo of Adam Johnson

Adam Johnson

  • 1,020 Points 1k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 18,126 Points 10k badge 2x thumb
You should be able to do this all pretty simply with Skuids actions.
1) open a popup
2) create a new record
3) populate fields
4) open another popup
5) close existing popup
6) conditionally render fields based on whether time has been entered or not..