Forums

Forums / Developing Portals / Select zero stars from a CRM Rating field

Select zero stars from a CRM Rating field

Thread is closed for posting
7 posts, 1 answered
  1. clefsrud
    clefsrud avatar
    26 posts
    Registered:
    24 Nov 2014
    14 Mar 2016
    Link to this post
    For the user of a CRM Rating field, selection can be made of any number of stars.  Once some non-zero number has been selected, it is possible to allow the user to revert back to zero?  Short of reloading the form?
  2. Clinton Bale
    Clinton Bale avatar
    126 posts
    Registered:
    21 Feb 2014
    14 Mar 2016 in reply to clefsrud
    Link to this post
    Hello Chris,

    A button can be made to reset the CRM Rating Field back to zero using JavaScript:

    findControl("CrmRatingField_C004").get_radRating().set_value(0);
    

    Regards,
    Clinton
    Last modified on 14 Mar 2016 16:03 by Clinton Bale
  3. clefsrud
    clefsrud avatar
    26 posts
    Registered:
    24 Nov 2014
    15 Mar 2016 in reply to Clinton Bale
    Link to this post
    Okay.  Thank you.
    I don't have any existing examples for using buttons or related reference material; a little help here please.  I have added a Submit button to the form with the Submit behaviour set to false, and assigned a unique CCSClass value; also added an empty Rules Manager component to the form.
    Added a Javascript component to the page.  Tried a number of variations to call the logic; only getting unhandled exceptions to this point.  So, where does this logic go, and how does it get called?  Am I missing anything else?
  4. clefsrud
    clefsrud avatar
    26 posts
    Registered:
    24 Nov 2014
    04 Apr 2016 in reply to Clinton Bale
    Link to this post
    Just hoping to get a bit more help on this; where do I place this logic statement?  I have tried several different options with no success.
  5. clefsrud
    clefsrud avatar
    26 posts
    Registered:
    24 Nov 2014
    04 Apr 2016 in reply to Clinton Bale
    Link to this post
    Okay, I figured out one issue I was encountering (testing issue; my form requires data from a prepared url).  However, I continue to be unable to prevent default behaviour either with a submit button or a multi-form button (referring to the "Add your "Back" button to CRM Form" forum posting.
    Tested my logic using a non-button trigger, works properly.  So just two issues remain, how to call the function from the button, and how to prevent default submit behaviour.
  6. Missing user
    Missing user avatar
    Answered
    04 Apr 2016 in reply to clefsrud
    Link to this post
    Hi Chris,

    I made an example regarding how you can set a rating fields' value to zero with the use of an HTML button.

    Firstly, drag an instructional text widget onto the body of your form then edit it. Click the HTML option located at the bottom of the text area to switch over to HTML editing mode. This is where we'll create a button as this will ensure that we have full control over what the button does unlike the Sitefinity submit button.



    <button id="btnReset" type="button">Reset Rating Field to Zero</button>

    You may also add any number of classes to this button to ensure that its style is inline with the rest of your website.

    Next, drag a JavaScript code block onto the body of your form and open it, then add this code to the code section:

    $(window).load(
       $("#btnReset").click(function() {
             findControl(".CrmRatingField_C007").set_value(0);
          })
    );
    

    This function will reset the rating field's value to zero when you click on the button. Make sure to check the 'Before the closing body tag' option in the JavaScript editor to ensure that J​Query has loaded before this function is run.



    Please let us know if you have any more questions or concerns.

    Kind Regards,

    Chris Rooney.
    Last modified on 04 Apr 2016 19:04 by Missing user
  7. clefsrud
    clefsrud avatar
    26 posts
    Registered:
    24 Nov 2014
    04 Apr 2016 in reply to Missing user
    Link to this post
    Excellent, thanks.  The button is what I was missing; was trying to use a widget button.
7 posts, 1 answered