Forum Discussion
QuickBaseCoachD
6 years agoQrew Captain
?a=API_GenAddRecordForm" will pop up an Add Record form for a human user to complete and manually save. That could only be used as the very last step in an API Button.
?a=API_AddRecord" will create a record.
You want to use the latter API
?a=API_AddRecord" will create a record.
You want to use the latter API
IvanWeiss
6 years agoQrew Captain
It is that same code, I just fixed that one line you mentioned. But it is not running that add API
//Button Functionality:
//1. Change the stage of the opportunity to won
//2. Set the Date Won to Today
//3. Check to see if opportunity is of type design.
// If true, assign a task to Lisa to create the sales order.
//4. Redirect back to the same form to display the record with updates.
//*******************************************************************************************************************
//Step 1 and 2
var text urlOne = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
"&rid=" & [Record ID#] &
"&apptoken=c5gchf9bhwx6umbd2ii5zdqtb5x8" &
"&_fid_9=Won" &
"&_fid_23=" & URLEncode(Today());
//Step 3 - Build urlTwo variable if the type is design. This assigns the sales order creation to lisa as a task.
var text urlTwoIfDesign = URLRoot() & "db/" & [_DBID_TASKS] & "?a=API_AddRecord" &
"&apptoken=c5gchf9bhwx6umbd2ii5zdqtb5x8" &
"&_fid_31=" & URLEncode(ToUser("ljording@elitestudioe.com")) &
"&_fid_36=" &URLEncode("Task created automatically through Opportunity Win Button") &
"&_fid_9=" & URLEncode(ToWeekdayN(Today())) &
"&_fid_12=" & [Record ID#] &
"&_fid_21=" & [Project] &
"&_fid_24=Active" &
"&_fid_38=" & URLEncode(ToText(ToUserList([Project Solutions T1],[Project Solutions T2]))) &
"&_fid_23=Opportunity" &
URLEncode("&_fid_83=Not Applicable") &
"&_fid_6=Create Sales Order - Design Opportunity";
//Step 3 - Build urlTwo variable if the type is build. THE FOLLOWING IS A COPY OF THE ABOVE AS I DID NOT BUILD THE LOGIC OUT YET
var text urlTwoIfBuild = URLRoot() & "db/" & [_DBID_TASKS] & "?a=API_AddRecord" &
"&apptoken=c5gchf9bhwx6umbd2ii5zdqtb5x8" &
"&_fid_31=" & URLEncode(ToUser("ljording@elitestudioe.com")) &
"&_fid_36=" &URLEncode("Task created automatically through Opportunity Win Button") &
"&_fid_9=" & URLEncode(ToWeekdayN(Today())) &
"&_fid_12=" & [Record ID#] &
"&_fid_21=" & [Project] &
"&_fid_24=Active" &
"&_fid_38=" & URLEncode(ToText(ToUserList([Project Solutions T1],[Project Solutions T2]))) &
"&_fid_23=Opportunity" &
URLEncode("&_fid_83=Not Applicable") &
"&_fid_6=Create Sales Order - Design Opportunity";
//Step 4
var text redirect = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#];
//URL Execution
Case(true,
[Opportunity Type] = "Design", $urlOne & URLEncode($urlTwoIfDesign) & "&rdr=" & URLEncode($redirect),
[Opportunity Type] = "Build", $urlOne & URLEncode($urlTwoIfBuild) & "&rdr=" & URLEncode($redirect)
)
//Button Functionality:
//1. Change the stage of the opportunity to won
//2. Set the Date Won to Today
//3. Check to see if opportunity is of type design.
// If true, assign a task to Lisa to create the sales order.
//4. Redirect back to the same form to display the record with updates.
//*******************************************************************************************************************
//Step 1 and 2
var text urlOne = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
"&rid=" & [Record ID#] &
"&apptoken=c5gchf9bhwx6umbd2ii5zdqtb5x8" &
"&_fid_9=Won" &
"&_fid_23=" & URLEncode(Today());
//Step 3 - Build urlTwo variable if the type is design. This assigns the sales order creation to lisa as a task.
var text urlTwoIfDesign = URLRoot() & "db/" & [_DBID_TASKS] & "?a=API_AddRecord" &
"&apptoken=c5gchf9bhwx6umbd2ii5zdqtb5x8" &
"&_fid_31=" & URLEncode(ToUser("ljording@elitestudioe.com")) &
"&_fid_36=" &URLEncode("Task created automatically through Opportunity Win Button") &
"&_fid_9=" & URLEncode(ToWeekdayN(Today())) &
"&_fid_12=" & [Record ID#] &
"&_fid_21=" & [Project] &
"&_fid_24=Active" &
"&_fid_38=" & URLEncode(ToText(ToUserList([Project Solutions T1],[Project Solutions T2]))) &
"&_fid_23=Opportunity" &
URLEncode("&_fid_83=Not Applicable") &
"&_fid_6=Create Sales Order - Design Opportunity";
//Step 3 - Build urlTwo variable if the type is build. THE FOLLOWING IS A COPY OF THE ABOVE AS I DID NOT BUILD THE LOGIC OUT YET
var text urlTwoIfBuild = URLRoot() & "db/" & [_DBID_TASKS] & "?a=API_AddRecord" &
"&apptoken=c5gchf9bhwx6umbd2ii5zdqtb5x8" &
"&_fid_31=" & URLEncode(ToUser("ljording@elitestudioe.com")) &
"&_fid_36=" &URLEncode("Task created automatically through Opportunity Win Button") &
"&_fid_9=" & URLEncode(ToWeekdayN(Today())) &
"&_fid_12=" & [Record ID#] &
"&_fid_21=" & [Project] &
"&_fid_24=Active" &
"&_fid_38=" & URLEncode(ToText(ToUserList([Project Solutions T1],[Project Solutions T2]))) &
"&_fid_23=Opportunity" &
URLEncode("&_fid_83=Not Applicable") &
"&_fid_6=Create Sales Order - Design Opportunity";
//Step 4
var text redirect = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#];
//URL Execution
Case(true,
[Opportunity Type] = "Design", $urlOne & URLEncode($urlTwoIfDesign) & "&rdr=" & URLEncode($redirect),
[Opportunity Type] = "Build", $urlOne & URLEncode($urlTwoIfBuild) & "&rdr=" & URLEncode($redirect)
)