Copy Formula

Tags:  

Copy Formula





Introduction


The Copy Formula API is used to copy one or more formula columns from one table to another within the same database or across databases and even across one user account to another. The source database administrator should generate and provide the Copy Database Key, the secret key used to authorize the destination database administrator. It is necessary that the table and column name in the destination database should be the same as that of the table and column names in the source database on which the formula is dependent. Both Custom Formula and Aggregate Formula can be copied using this API.


Getting Started


It is recommended to go through the Zoho Reports API Prerequisites before using Copy Formula API.


Request


The sample request URL is below.


https://reportsapi.zoho.com/api/source@zoho.com/SourceEmployeeDB/SourceEmployeeDetails?ZOHO_ACTION=COPYFORMULA
&ZOHO_FORMULATOCOPY=MyFormula1,MyFormula2&ZOHO_DATABASE_NAME=DestinationEmployeeDB
&ZOHO_COPY_DB_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxx
&ZOHO_OUTPUT_FORMAT=XML&ZOHO_ERROR_FORMAT=XML
&authtoken=g38sl4j4856guvncrywox8251sssds&ZOHO_API_VERSION=1.0
 



Query String Parameters

The below table shows the list of Query String parameters that has to be passed along with the request URL.

Parameter NameDescription
ZOHO_ACTIONThis parameter value should be COPYFORMULA

Note;
This parameter should be in the same case(UPPER CASE) as given in this document.
ZOHO_FORMULATOCOPYThis parameter holds the FORMULA NAME to be copied from the source database into another table in the destination database. In case more than one formulas are to be copied, the formula names should be separated by comma ( , ).

Example:
ZOHO_FORMULATOCOPY=MyFormula1,MyFormula2,MyFormulaN
ZOHO_DATABASE_NAMEThis parameter holds the name of the database (destination database) where the destination table is present. The specified formula are copied to the table which has same name (SourceEmployeeDetails) as specified in the API URL
ZOHO_COPY_DB_KEYThe secret key used for allowing the user to copy the database / reports. The source database owner has to invoke the below URL to get the Copy Database Secret Key.

https://reportsapi.zoho.com/api/abcd@zoho.com/MyOldEmployeeDB?ZOHO_ACTION=GETCOPYDBKEY&ZOHO_OUTPUT_FORMAT=XML&ZOHO_ERROR_FORMAT=XML
&authtoken=<
source_db_owner_authtoken>&ZOHO_API_VERSION=1.0

Note: You need to provide the appropriate values in the above URL to generate the corresponding Copy Database Key for your setup

authtoken
The authtoken parameter should hold the Auth Token of the Destination Database Owner Account.


Response


The sample response sent from the server if the Copy Formula process is successful.

XML Format:

<response uri="/api/source_account@zoho.com/SourceEmployeeDB/SourceEmployeeDetails" action="COPYFORMULA">
<result>
<message>Successfully formula(s) Copied</message>
</result>
</response>


JSON Format:

{
"response":
             {
         "uri":"\/api\/source_account@zoho.com\/SourceEmployeeDB\/SourceEmployeeDetails",
         "action":"COPYFORMULA",
         "result":
 {
                         "message": "Successfully Formula(s) Copied"
 }
 }
}



Error Handling



This section explains about the error response sent from the Zoho Reports server on failure of Copy Formula API. The sample error response is below.

XML Format:

<response uri="/api/source_account@zoho.com/SourceEmployeeDB/SourceEmployeeDetails" action="COPYFORMULA">
<error>  <code>15009</code>
<message>The formula 'MyFormula1' is already copied to the destination table 'SourceEmployeeDetails' of database '3835000001921187'.</message>
</error>
</response>


JSON Format:

{
"response"
:
{
"uri
": "\/api\/source_account@zoho.com\/SourceEmployeeDB\/SourceEmployeeDetails",
"action"
: "COPYFORMULA",
"error"
:
{ "code":15009,
"message"
: "The formula 'MyFormula1' is already copied to the destination table 'SourceEmployeeDetails' of database '3835000001921187'."
}
}
}



Error Codes:

The below table shows the list of error codes sent from server on Copy Report API Request along with the reason and the solution for the same.

Error CodeReasonSolution
15000A table into which the formula is to be copied is missing in the destination databaseCheck the destination database and create / copy the missing table / query table
15001
A column which is needed to copy the formula is missing in the destination database
Check the destination database and create the necessary columns before copying the formula
15002
A formula column which is needed to copy the specified formula column is missing in the destination databaseCheck the destination database and create / copy the required formula column before copying the specified formula column
15007Insufficient privileges to copy the reportCheck whether the Copy Database Key is valid
15009
The formula column name specified already exists in the destination database
Check whether the formula column is already copied, otherwise, try renaming the formula column in the source table or in the destination database and invoke the API again
15010
The Formula Column name specified in the API request is not present in the Source Database
Check the formula column name(s) specified in the ZOHO_FORMULATOCOPY parameter is correct


In case you encounter any other errors, please mail the API request URL parameters and error response details to support@zohoreports.com. We will get back to you shortly with the best possible solution.





    Post a comment

    Your Name or E-mail ID (mandatory)

    Note: Your comment will be published after approval of the owner.




     RSS of this page