• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: change field on directory email

change field on directory email 9 years 10 months ago #31354

I have the following script called before directory email.
$db = JFactory::getDbo();
$db->setQuery(
"UPDATE #__rsform_submission_values 
SET `FieldValue`='".date('m/d/Y')."' 
WHERE `SubmissionId`=".$SubmissionId."
AND FieldName='Date Approved' "
);
$db->query();
I want it to only execute this if another field has a value of "Approved". Is that possible?
The administrator has disabled public write access.

change field on directory email 9 years 10 months ago #31591

Anyone?
The administrator has disabled public write access.

change field on directory email 9 years 10 months ago #31609

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
I will provide an example using the script from our documentation.
$submissionId = JRequest::getInt('id');
$db = JFactory::getDbo();
 
$db->setQuery("UPDATE #__rsform_submissions SET `DateSubmitted`='".date('Y-m-d G:i:s')."' 
WHERE `SubmissionId`='".$submissionId."' AND `confirmed` = '1' " );
$db->query();  

Basically, this will update only if the corresponding value from the 'confirmed' column is 1.

The example on which this script is based is here:

https://www.rsjoomla.com/support/documentation/rsform-pro/custom-scripting/rsformpro-manage-directories-scripting-examples-.html

PS: the above does not have a condition, it will automatically update the submission date regardless of the value in the confirm column.
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

change field on directory email 9 years 9 months ago #31890

  • djaber2000
  • djaber2000's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 33
  • Thank you received: 3
Hi, I am trying to accomplish the exact same with the script you are using; Update a field with the current date, based on another fields value having 'Approved'. The script you are using is from the "Last edited Date" tutorial page here, which I am also using: www.rsjoomla.com/support/documentation/r...sions-directory.html

Were you ever able to get it to execute based on another fields value, rather than updating the date every single time?

The example provided by cosmin relates to the rsform_submissions table, and not the rsform_submissions_value table which is where the field value to check against is stored.


I tried using a AND EXISTS, and still no luck:
$db = JFactory::getDbo();
$db->setQuery("UPDATE #__rsform_submission_values SET  `FieldValue`='".date('m/d/y H:i:s')."' WHERE `SubmissionId`=".$SubmissionId."
AND
FieldName = 'ApprovedDate'
AND
EXISTS ("SELECT * FROM #__rsform_submission_values
                   WHERE FieldName = 'status'
                     AND 'FieldValue' = 'Approved'
                     AND `SubmissionId`=".$SubmissionId." )");
$db->query();

Using CASE may be an option, but I am not sure if it will work with Jdatabase.


There are 5 columns in the _value table and the user field values are stored in a single column called FieldValue. I belive this is an EAV setup, which is a little different then what we may be used to, where we can just use "SET name_field = date(m/d/Y)"

(SubmissionValueId FormId SubmissionId FieldName FieldValue )


Any suggestions or thoughts?
Last Edit: 9 years 9 months ago by djaber2000.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!