NetTalk Central

Author Topic: Refreshing the comment field on demand  (Read 4380 times)

kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Refreshing the comment field on demand
« on: February 13, 2015, 09:57:02 PM »
I'm adding code to conditionally set the text in the comment. I do this in the 4 Comment Routine Embed of a field (Enr:Eligibility) on a tab.  See the attached image embed.png.  This code checks the contents of another field (Enr:Exclusion01) and sets the text accordingly.  See the attached image code.png.

When I go to this tab the comment is set as expected.  Then, if I go to another tab, change the content of the other field, and return to the tab, the comment is not updated.  I have tried using do comment::Enr:Eligibilty and tried resetting the entire field with do Value::Enr:Eligibility.  Still the comment is not updated as expected.

Any ideas?

Thanks,

Jeff

[attachment deleted by admin]

kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Re: Refreshing the comment field on demand
« Reply #1 on: February 14, 2015, 10:40:58 AM »
To summarize, I have a procedure routine created containing code that checks the data in various fields on a form.  I want to find the best embed to call this routine so that it can test various fields and then cause the comments to update as required.  I want this to occur before saving the form.

I have made some progress but it is not perfect yet.  For example, I call this procedure during a tab change and it works.  Ideally I want it to "monitor" the form and run as needed, or perhaps run from a custom button when clicked.

Thanks,

Jeff
« Last Edit: February 15, 2015, 02:39:34 PM by kingja »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Refreshing the comment field on demand
« Reply #2 on: February 15, 2015, 09:51:26 PM »
Hi Jeff,

your IF statement in the code is wrong.

You have;
If Enr:Elligibility = 'Yes'

this shoudl be
If p_web.GetSessionValue('Enr:Elligibility') = 'Yes'

Always remember to use Session variables on a form when using fields in comparisons or conditions or wherever.

In terms of refreshing the comment itself when something changes - this can be done with the Reset Fields list on the field which is changing and hence triggering a refresh.

cheers
Bruce


kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Re: Refreshing the comment field on demand
« Reply #3 on: February 16, 2015, 05:01:49 AM »
Bruce,

Thanks, using the session variable helped solve most problems.  I do have two more questions:

What about resetting same field.  For example, if I change the eligibility field, should I put a reference to it in its own reset field list?  Or does it reset automatically?

Is it possible to call a procedure routine from a button, when clicked?  I see in the templates where I can call a procedure but don't see how to call a procedure routine.

Thanks,

Jeff
« Last Edit: February 16, 2015, 05:03:58 AM by kingja »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Refreshing the comment field on demand
« Reply #4 on: February 17, 2015, 03:06:28 AM »
Hi Jeff,

>> What about resetting same field.  For example, if I change the eligibility field, should I put a reference to it in its own reset field list?  Or does it reset automatically?

first, remember that if you change an (incoming) field, you need to store the change in the Session Value, not just the field itself.

If you want a field to reset itself you should add it to it's own reset list.

Is it possible to call a procedure routine from a button, when clicked?  I see in the templates where I can call a procedure but don't see how to call a procedure routine. Some fields will reset themselves by default (if the template thinks it needs to do that) but that which goes without saying, goes better with saying. So being explicit is also good.

>> Is it possible to call a procedure routine from a button, when clicked?  I see in the templates where I can call a procedure but don't see how to call a procedure routine.

The Validate::Fieldname routine is called when the button is pressed. A simple
do whatever
call in there will call your routine.

Cheers
Bruce

kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Re: Refreshing the comment field on demand
« Reply #5 on: February 17, 2015, 11:45:14 AM »
Bruce,

     I have not had any success with this technique.  Here is some test code I'm using:

If  p_web.GSV('Enr:Inclusion_Criteria_1') = 'Yes' AND|
    p_web.GSV('Enr:Inclusion_Criteria_2') = 'Yes' AND|
    p_web.GSV('Enr:Inclusion_Criteria_3') = 'Yes' AND|
    p_web.GSV('Enr:Inclusion_Criteria_4') = 'Yes' AND|
    p_web.GSV('Enr:Inclusion_Criteria_5') = 'Yes' AND|
    p_web.GSV('Enr:Inclusion_Criteria_6') = 'Yes' AND|
    p_web.GSV('Enr:Exclusion_Criteria_1') = 'No'  AND|  
    p_web.GSV('Enr:Exclusion_Criteria_2') = 'No'  AND|        
    p_web.GSV('Enr:Exclusion_Criteria_3') = 'No'  AND|
    p_web.GSV('Enr:Exclusion_Criteria_4') = 'No'  AND|
    p_web.GSV('Enr:Exclusion_Criteria_5') = 'No'  AND|
    p_web.GSV('Enr:Exclusion_Criteria_6') = 'No'  AND|
    p_web.GSV('Enr:Exclusion_Criteria_7') = 'No'
    
    p_web.SSV('Enr:Eligibility', 'Yes')
    
 ELSE

    p_web.SSV('Enr:Eligibility', 'No')

 END
    
    If p_web.GSV('Enr:Informed_Consent_Signed') = 'Yes' AND p_web.GSV('Enr:Status') <> 'On Study'
        p_web.SSV('Enr:Status', 'Screening')
    END    
        
    If p_web.GSV('Enr:Informed_Consent_Signed') = 'Yes' AND p_web.GSV('Enr:Eligibility') = 'Yes'
        p_web.SSV('Enr:Status', 'On Study')    
    END
    
    !do comment::Enr:Eligibility
    do refresh::Enr:Eligibility
    do refresh::Enr:Status
    do refresh::Enr:Date_Consent
    

 This code works when in the CheckIncExcCriteria routine which I call from the Change Tab embed.  I have not been able to get it to work in the Validate::btnCheckEnrollment routine of my button.  Any other thoughts?

Jeff



« Last Edit: February 17, 2015, 05:22:21 PM by kingja »

kingja

  • Sr. Member
  • ****
  • Posts: 261
    • View Profile
    • Email
Re: Refreshing the comment field on demand
« Reply #6 on: February 17, 2015, 08:37:27 PM »
Bruce,

     To follow up, I have this working now, using the Validate::Field, 3 Start embed.  It is a bit of a mystery as earlier in the day I could not get this to work.  Now, after a few recompiles it is working.

Thanks,

Jeff