Jump to content
  • 0

CASE in calculated field


nuimage

Question

Hello,

Please help!  i'm a newbie to Caspio.   I want to update a Table value but can't figure out how to do this.

I have created a Reports Datapage and would like to UPDATE CourseStatus to 'Not Active' when @calcfield1 >= MaxParticipants. 

MaxParticipants (fieldname)
CourseStatus      (fieldname)

 

@calcfield1= count of participants
SELECT COUNT(*) FROM iied_tlpreg_Participants WHERE iied_tlpreg_Participants.Course_RECID = [target].[@field:Course_RECID]

@calcfield2 = CASE
                              WHEN[@calcfield:1] >= [@field:MaxParticipants]
                              THEN  'Not Active'
                             ELSE 'Published'
                         END

CourseStatus is a hidden field in the data page and on load, receives the datasource field @calcfield2.  I can see the correct value from the data page but the Table doesn't get updated.

 

Any help on how to update the field is appreciated!

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 1

Hello nuimage,

Please note that  @calcfield2 will have value after page load as per your described workflow, hence.

I would suggest having two Datapages (Report&Single record update form) to replicate your workflow.

On your Report Datapage you can place a link in HTML block to Single record update form and pass @calcfield2 value as a query string.

Parameters-as-query-string-values

Hope this helps.

Link to comment
Share on other sites

  • 0

Hello Vitalikssssss, 

Is there a way to update the record dynamically without creating a Single record update form?  I have a registration page that list all "Published" courses.  This status is set when the course is created.  However, when the criteria is met (student count >= MaxParticipants allowed for course) I would like to update the the field "CourseStatus" with the value  "Not Active".  Essentially, the updated status would  remove the course from the Published list of courses.  

Thanks again for your help!

 

 

 

Link to comment
Share on other sites

  • 0
17 hours ago, nuimage said:

Hello Vitalikssssss, 

Is there a way to update the record dynamically without creating a Single record update form?  I have a registration page that list all "Published" courses.  This status is set when the course is created.  However, when the criteria is met (student count >= MaxParticipants allowed for course) I would like to update the the field "CourseStatus" with the value  "Not Active".  Essentially, the updated status would  remove the course from the Published list of courses.  

Thanks again for your help!

 

 

 

Hi nuimage,

I do not beliave that this is possible.

Perhaps you may take a look at method described on Howto:

http://howto.caspio.com/tech-tips-and-articles/advanced-customizations/how-to-limit-the-number-of-submissions/

Hope this helps.

 

Link to comment
Share on other sites

  • 0

Hello Vitalikssssss,

I've reviewed  the article countless times on "how to limit the number of submissions" but still cannot get the form to update the courses table.   I did correct a small typographical error in the javascript (semicolon missing from first edit record statement) that updates the page but still without success.  What am i missing?  Below is the the javascript from my single record update page.   

Unique ID field - Course_ID

Parameter name - [@cid]

Attendees - field to update

 

Header code - <div style="display:none">

Footer code - </div>
                         <script>
                            document.getElementById('EditRecordAttendees').value;

                            parseInt(document.getElementById('EditRecordAttendees').value) + 1;
                            document.getElementById('caspioform').submit();
                          </script>

 

Destination after record update goes to a new data page.  I'm forwarded to the new page as expected and do receive the confirmation message that i crafted, but the Attendees field in the Courses table is never updated.

Thanks for your input!

Link to comment
Share on other sites

  • 0
14 hours ago, nuimage said:

Hello Vitalikssssss,

I've reviewed  the article countless times on "how to limit the number of submissions" but still cannot get the form to update the courses table.   I did correct a small typographical error in the javascript (semicolon missing from first edit record statement) that updates the page but still without success.  What am i missing?  Below is the the javascript from my single record update page.   

Unique ID field - Course_ID

Parameter name - [@cid]

Attendees - field to update

 

Header code - <div style="display:none">

Footer code - </div>
                         <script>
                            document.getElementById('EditRecordAttendees').value;

                            parseInt(document.getElementById('EditRecordAttendees').value) + 1;
                            document.getElementById('caspioform').submit();
                          </script>

 

Destination after record update goes to a new data page.  I'm forwarded to the new page as expected and do receive the confirmation message that i crafted, but the Attendees field in the Courses table is never updated.

Thanks for your input!

4

Hi nuimage,

I see that you have missed an assignment operator '=' in your code after "document.getElementById('EditRecordAttendees').value":

So code in Footer should look like this:

</div>
<script>
document.getElementById('EditRecordAttendees').value = parseInt(document.getElementById('EditRecordAttendees').value) + 1;
document.getElementById('caspioform').submit();
</script>

 

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...