Jump to content
  • 0

Cron Job To Update A Calculated Value


clicknip

Question

I need to be able to search on an "age" field. To be current, the age field would be calculated using the birth date. How can I periodically update the age field? Can I use some kind of cron job to update the value?

 

(This is related to an earlier post, http://forums.caspio.com/index.php/topic/4039-working-with-calculated-age-from-date-of-birth/. Apparently I can't do what I need to do with a calculated field in a report.)

 

Thanks in advance!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi, Clicknip

 

As I can see in the Caspio Idea Box (http://ideabox.caspio.com/forums/164206-caspio-bridge/suggestions/2905340-calculated-field-to-be-stored-in-table), table-level calculations and formulas are in the road map for future releases. I think this feature is what you need.

 

Until this feature is released, the only way is to create new column in the table and insert age for each record (or you can do this in Excel via formula and then import this excel table to the Caspio)

Link to comment
Share on other sites

  • 0

Thanks for you comment and the heads up, ShWolf.

 

Once I got the API setup working (a little tricky, since I'm not a hardcore developer), I was able to do the calculation and update the data that way. I would just need to have a regular cron job of some kind hit the php page. Here's what the code looks like, minus my account details. It follows the code style in the API documentation.

 

function updateAge()
{
global $wsdl,$AccountID,$ProfileName,$Password;
 
    try
    {
//init the SOAP Client
$SoapClient = new SoapClient($wsdl);
 
$affected=$SoapClient->UpdateData($AccountID, $ProfileName, $Password,
"BB_Model", false,
"Age",
"datediff(day,Birth_Date,getdate())/365");
}
catch (SoapFault $fault)
{
//SOAP fault handling
$str = "<h1><b>Fault:</b> faultcode: {$fault->faultcode}, <b>faultstring:</b> {$fault->faultstring}</h1>";
print($str);
}
}
Link to comment
Share on other sites

  • 0

Hi clicknip,

Caspio Bridge has a new feature which is called Task and is somewhat equivalent to a CRON job. You can now create Tasks to enhance the level of automation in your applications. Tasks can modify data and send email or SMS notifications based on a predefined time schedule. With Tasks, your applications can run operations on a predetermined schedule and automatically do all the steps that you configured in them. You can find more information here. It is included in the release of Caspio Bridge 15.0 last October 16, 2018. 

I hope this information helps.

Cheers!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...