locked
Conditional Formatting in Custom Newform Based on Value in Different List RRS feed

  • Question

  • Hi All,

    Running MOSS.

    I have two lists: one with Upcoming Events as items, and one for Registrants. They are tied by an Event ID (as a common field) that we create for each event. An event may or may not have a fee associated with it; the fee is a column in the Upcoming Events list.

    When someone signs up for an Event, I have customized a version of Newform to collect information for the Registrants list. I have fields for Cardholder payment information in the Newform1, which I would like to hide if the fee in the Upcoming Events list equals zero. I have looked at Conditional Formatting, but don't see a way to look outside of the Registrants list for the info.

    I have read about event receivers, but I don't know or have Visual Studio. I was thinking about a workflow, but the registrants may be unauthenticated users (anonymous), which creates an error page to those users when workflows are triggered. I have seen discussions of javascript solutions as well, but they tend to be somewhat off-base and they go into areas that lose me.

    The Event ID gets populated to the Registrants list via some custom coding done by someone else (who is no longer available to be consulted). If condtional formatting based on a value in a different list is not possible, I would be interested in any ideas to populate the Fee amount automatically as a new column in the Registrants list. Via my browser, I tried adding this is as a Lookup field, but when selecting the Upoming Events list as the source, the Fee field was not an available choice.

    If someone could point me in the right direction, using SharePoint Designer, I would be greately appreciative.

     

    Thanks and best wishes,

    Eric

     

    Tuesday, May 17, 2011 9:38 PM

Answers

  • Thanks for the kind words Eric,  without knowing what this developer did in ASP.NET it's hard to say for sure what the best approach would be because I don't know how the NewForm.aspx page is getting loaded.  

    This scenario is very similar to the scenario in my previous blog example, but instead of "issues" you have "events" and instead of "time" you have registrants. 

    If you are dead set on using the .net code that the previous developer put in place, can you give more information on how that works and what the code looks like? Maybe post the page's source code for the section around the "register" button? 

    We'll get this figured out...

    Good luck,
    Mark 


    The SharePoint Hillbilly
    Fewer Big Words... More Pretty Pictures... http://www.SharePointHillbilly.com
    • Marked as answer by Leoyi Sun Thursday, May 26, 2011 9:47 AM
    Thursday, May 19, 2011 12:18 AM

All replies

  • Hey Eric, it seems like you have a lot going on here. If I understand you correctly, it sounds like yo have two things you want:

    1) Hide the payment information on the registrant new item form if there are no fees for the event

    2) Populate the Fee amount in the registrant new item form.  

    What "custom coding" was done to populate the event id?  You do NOT need to do any custom coding, and it can all be done via SPD using the method found in my blog:

    http://sharepointhillbilly.com/archive/2009/12/08/creating-a-sharepoint-list-parentchild-relationship-ndash-video-remix.aspx

    you would just want to pass an additional Query String Variable for the fee to the new item form of the registration.

    You could also write some very simple JavaScript/jQuery to hide the payment information fields if the value of the fee was "0" or something like that.  

     

    Take a look a the blog post and see if it gives you any ideas, it's a fairly easy to follow video series that should help.

     

    if I am not understanding you correctly, please let me know where I'm confused.

    Thanks and good luck!

    Mark


    The SharePoint Hillbilly
    Fewer Big Words... More Pretty Pictures... http://www.SharePointHillbilly.com
    Wednesday, May 18, 2011 12:52 AM
  • Thanks a lot Mark. Sounds like you understand the situation correctly. My main goal is 1) above; if that's not directly possible and I can accomplish 2), I know I can use Conditional Formatting to then hide the relevant fields using SPD. I'm assuming the previous programmer used ASP.NET for his work on the Event ID field, though I'm not sure.

     

    I have liked the JavaScript idea from the beginning, but was getting lost and still am. Before I posted here, I actually spent a fair amount of time reading your blog entries related to the video, two or three of them  if I remember right. (By the way, I enjoy your writing style and sense of humor.)

     

    My main issue is getting my head around which steps apply to my situation and which don’t. And the part about passing an “additional Query String Variable for the fee to the new item form of the registration” makes sense, but is tripping me up. Logic also tells me that I need a way to take the Event ID from the Registrants list and find it in the Upcoming Events list to return the Fee for that item. Maybe that’s what the Query String Variable is doing, but I’m not sure.

     

    Thanks again. Your assistance is valued.

     

     

    Best wishes,

     

    Eric

    Wednesday, May 18, 2011 6:05 PM
  • Thanks for the kind words Eric,  without knowing what this developer did in ASP.NET it's hard to say for sure what the best approach would be because I don't know how the NewForm.aspx page is getting loaded.  

    This scenario is very similar to the scenario in my previous blog example, but instead of "issues" you have "events" and instead of "time" you have registrants. 

    If you are dead set on using the .net code that the previous developer put in place, can you give more information on how that works and what the code looks like? Maybe post the page's source code for the section around the "register" button? 

    We'll get this figured out...

    Good luck,
    Mark 


    The SharePoint Hillbilly
    Fewer Big Words... More Pretty Pictures... http://www.SharePointHillbilly.com
    • Marked as answer by Leoyi Sun Thursday, May 26, 2011 9:47 AM
    Thursday, May 19, 2011 12:18 AM
  • Thanks again Mark. I certainly see the similarities between the example in your “Parent/Child Relationship” posts and what I’m doing. On more than one occasion, I’ve been tempted to abandon a lot of the work done to date and adopt the structure you propose. I guess I am still hoping for a quicker fix that would work for me.

      

    I am by no means set on using the work of the previous programmer. I just don’t want to unintentionally break something that is already working somewhere else.

     

    I took another look at the custom registration form. As you suggested, I selected the Submit button in Design View in SPD and the related code is very simple and obvious. I was surprised to learn that I don’t see a lot of code elsewhere in the file that I don’t understand, except for the following bit of JavaScript. FYI, it’s below the </WebPartPages:DataFormWebPart> tag, near the bottom of the file.

     

    <script type="text/javascript">

                                        function getQueryVariable() {

                                        var variable ="eid";

                                        var id = "ctl00_PlaceHolderMain_g_4986eca9_1627_43f4_927c_8e534bf0e143_ff1_1_ctl00_ctl00_TextField"

                                        var query = window.location.search.substring(1);

                                        var vars = query.split("&");

                           

                                         for (var i=0;i<vars.length;i++) {

                                           var pair = vars[i].split("=");

                                                   

                                           if (pair[0] == variable) {

                                           document.getElementById(id).value = pair[1];

                                           //document.getElementById(id).disabled="disabled";

                                           //return pair[1];

                                          }

                                         }

                                        }

                                        getQueryVariable();

                                        </script>

     

     

    This seems like it’s doing something that I may build on to pass the Fee information to the Registrants list, but I’m not entirely sure of anything at this point. I will do some research on the “getQueryVariable” function and see what I can learn.

     

    I look forward to any continued guidance.

     

     

    Thanks and best wishes,

     

    Eric
    Thursday, May 19, 2011 6:47 PM
  • Thanks again Mark. Success at long last!

    I was able to auto-populate the Fee amount in the Registrants list, so that I could apply Conditional Formatting to the other fields. Since the Fee info was displayed on the previous page users see before the custom Newform, I appended that field to the URL. I then followed your instructions from your posts as relevant. Worked like a charm, but took some thinking and work.

    FYI, the specific post I found most useful was: http://geekswithblogs.net/SoYouKnow/archive/2009/10/29/setting-sharepoint-form-fields-using-query-string-variables-without-using.aspx.

    I appreciate the help and all of your time. It was very generous of you.

    Best wishes,

    Eric

    Sunday, May 29, 2011 2:05 AM