Results 1 to 3 of 3

Thread: Cache issue on custom view...VERY STRANGE

  1. #1
    ajlisowski is offline Sugar Community Member
    Join Date
    Jul 2010
    Posts
    56

    Default Cache issue on custom view...VERY STRANGE

    So, this issue is crazy and Im not sure how to fix it.

    Basically I have a module for a sales opportunity. Creating a record of this module can be done normally, in which case you select the customer it is for via a relate field.

    However it can also be done from the customer screen by click an "Open Opportunity" button. This brings you to the edit view of the opportunity module, with an additional parameter for customerID passed.

    I customized the edit view of the opportunity module so that I pass a variable to smarty called useCustomer and the customerID if a customerID is present.

    The template then checks if useCustomer is set and instead of writing the relate field for customer, it simply writes a hidden field and stores the customer.

    This works great. Except, the customer field will always do what it did right after repairing from the admin.

    Meaning, if I repair from admin, then normally go to create a new opportunity, customer will be there. Then even if I access it from the customer, where it should be hidden, customer still appears.

    Vice versa is true, if I first access it from a customer, no customer field is shown, it is hidden with the passed param. If I then access it normally, still no customer field, instead a hidden field with no value.

    The very very very strange thing is, if I output the variable I am checking right before my if statement, it properly shows. So Test: {$useCustomer} will show Test: 1 if I access it from a customer, and Test: if I do not.

    Somehow, the template is ignoring the if statement and just doing what it did before. I know the LOGIC of the code works, because if I repair/rebuild and run the other way, it will work. So somehow, the system seems to be caching the actual decision of the if statement in the template, if that makes any sense. Its very very strange to me and I cant remotely figure out why this is occuring.

  2. #2
    ajlisowski is offline Sugar Community Member
    Join Date
    Jul 2010
    Posts
    56

    Default Re: Cache issue on custom view...VERY STRANGE

    So, for some reason the edit template uses double brackets in a lot of places. {{ }} instead of {}

    I ran a small test at the top of the template

    Hi {$useCustomer}
    {if $useCustomer==1}
    USE CUSTOMER
    {else}
    DONT USE CUSTOMER
    {/if}

    Hi {{$useCustomer}}
    {{if $useCustomer==1}}
    USE CUSTOMER
    {{else}}
    DONT USE CUSTOMER
    {{/if}}

    The double brackets cause the error I see, where the page will always do what it originally did after repairing. The single bracket acts correctly and outputs the correct data every time.

    My issue is, once I replace my if statements with single brackets, the whole page goes capoot. Im not sure why these double brackets are needed or what they are doing. Any ideas?

  3. #3
    ajlisowski is offline Sugar Community Member
    Join Date
    Jul 2010
    Posts
    56

    Default Re: Cache issue on custom view...VERY STRANGE

    SOLVED!

    So first off apparently double brackets tell Sugar to cache the result in the cache file. This alone explains why I was experiencing the issue I was experiencing. The first time after repairing, it wou;d cache the file, using the result of the variable in the cache. Yay.

    Now why did removing the double brackets blow up my program? I am not 100% sure. BUT.

    Evaluating $colData.field.name with single brackets ALWAYS returned the final element of the form. Double brackets correctly returned the iterated field. The issue was, my code was specifically looking for the final field and not displaying it under certain circumstances. This lead the loop to go through and not display every field because when evaluated with single brackets thats what was returned.

    The question remains WHY was that the case, but I dont know or care really.

    Solving the problem required turning my if statement with an && into two seperate if statements. One checking the uncached value of $useCustomer and one checking the cached value of $colData.field.name.

    Problem solved...but still a bit confused. So if anyone can tell me why the $colData.field.name was returning the final field name every iteration when accessed outside of the cache, please let me know.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Custom Detail View Button working issue with functions
    By chrislynch8 in forum Developer Help
    Replies: 3
    Last Post: 2010-11-25, 03:54 AM
  2. Strange issue in the Emails
    By rajaseeth in forum Help
    Replies: 0
    Last Post: 2009-12-15, 03:10 PM
  3. Replies: 10
    Last Post: 2008-06-16, 08:35 AM
  4. Problem while Add Custom Fields -strange issue
    By xMOe in forum Developer Help
    Replies: 0
    Last Post: 2006-09-06, 02:31 PM
  5. Strange Themes Issue
    By Shoregeek in forum General Discussion
    Replies: 1
    Last Post: 2006-03-01, 07:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •