Announcement

Collapse
No announcement yet.

Validating from vis_custbe

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Validating from vis_custbe

    Hi folks,

    I think this may have been discussed before, but I couldn't find it by searching the archive. I'm trying to write some vis_custbe code for a module, and I'm having trouble getting Module_Customer_BatchEdit_Validate to work. How does this function differ from Module_Customer_Validate?

    My Module_Customer_Validate is already working fine. It's fairly simple; it just has to do some custom validation on the customer's login name, which it gets from g.Customer_Login. It also checks the value of g.Edit_Customer to see whether or not the admin user has entered a new login.

    My Module_Customer_BatchEdit_Validate function doesn't seem to be working at all. I changed it to a one-line <MvFUNCRETURN VALUE="0">, and it isn't signalling any error or stopping the updates from occurring. (And yes, I remembered to include vis_custbe in the features list.) Do I have to use different variable names instead of the usual g.Edit_Customer, g.Customer_Login, etc.? If the module needs to signal an error, do I have to write a different return function instead of FieldError?

    Thanks --

    Last edited by Kent Multer; 09-05-16, 07:54 PM.
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    Follow-up: I checked the LSK, and there are NO modules in there that use the vis_custbe feature. Or vis_productbe, or vs_categorybe.

    Fellow free-lancers, have any of you written code for any of these features? If so, I'd appreciate it if you could send me a code snippet.

    If no one is using these features, it seems possible that there are bugs in there,

    Thanks --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment


      #3
      Those functions will not be called unless your module reports an api_ver of 5.70 or newer. Also, since 9.00, they are only called when updating content on a module-provided tab on the Catalog or Customer screens.

      Comment


        #4
        Thanks, Burch, that should help.

        When you wrote "since 9.00," are you referring to Merchant version 9, or the module's api_ver value?

        My module doesn't put any new content on the batch-list page; it just does extra validation on the login. And I don't think there's any documentation or code examples of how to use tabs on the batch-list pages. Should I create a unique tab code for my module? Or should I use one of the existing codes such as CUST or IDEN?

        Thanks --
        Kent Multer
        Magic Metal Productions
        http://TheMagicM.com
        * Web developer/designer
        * E-commerce and Miva
        * Author, The Official Miva Web Scripting Book -- available on-line:
        http://www.amazon.com/exec/obidos/IS...icmetalproducA

        Comment


          #5
          Ken,

          My understand is that originally this allowed a module to take action of the customer does something on one of the batch screens like adding or deleting a product, as shown below, however they now have _Tabs,_Content, and _Head functions so we can add our own tabs and content to the batch screens.

          For example in MM9 on the Catalog page you now have Products | Categories | Attribute Templates etc. and I think you can add your own tabs and content here.

          This requires <MvASSIGN NAME = "l.module:api_ver" VALUE = "5.70"> but I recommend 5.73 as the minimum that you should use

          To date, the old API is all I've ever used as shown below.
          Code:
          <MvCOMMENT>  vis_productbe Functions </MvCOMMENT>
          <MvFUNCTION NAME="Module_Product_BatchEdit_Delete" PARAMETERS="module var, product var" STANDARDOUTPUTLEVEL = "">
              <MvFUNCRETURN VALUE="{ Module_Product_Delete(l.module, l.product) }">
          </MvFUNCTION>

          The code below was generated by my Online Module Builder -- http://pdqcoders.com/Miva-Merchant-Module-Builder.html. I put the entire API into database tables
          and is current as of API Reference Guide version 2.4 Note version 3.0 is available


          Code:
          <MvFUNCTION NAME="Module_Product_BatchEdit_Content" PARAMETERS="module var, tab, load_fields" STANDARDOUTPUTLEVEL="text,html,compresswhitespace">
              <MvCOMMENT> API: 5.70 </MvCOMMENT>
          
              <MvFUNCTIONRETURN VALUE = 1>
          </MvFUNCTION>
          
          <MvFUNCTION NAME="Module_Product_BatchEdit_Delete" PARAMETERS="module var, product var" STANDARDOUTPUTLEVEL="">
              <MvCOMMENT> API: 5.70 </MvCOMMENT>
          
              <MvFUNCTIONRETURN VALUE = 1>
          </MvFUNCTION>
          
          <MvFUNCTION NAME="Module_Product_BatchEdit_Head" PARAMETERS="module var, tab" STANDARDOUTPUTLEVEL="text,html">
              <MvCOMMENT> API: 5.70 </MvCOMMENT>
          
              <MvFUNCTIONRETURN VALUE = 1>
          </MvFUNCTION>
          
          <MvFUNCTION NAME="Module_Product_BatchEdit_Tabs" PARAMETERS="module var" STANDARDOUTPUTLEVEL="">
              <MvCOMMENT> API: 5.70 </MvCOMMENT>
          
              <MvFUNCTIONRETURN VALUE="{ toupper(l.module:code) $ ':' $ l.module:name }">
          </MvFUNCTION>
          
          <MvFUNCTION NAME="Module_Product_BatchEdit_Update" PARAMETERS="module var, product var" STANDARDOUTPUTLEVEL="" ERROROUTPUTLEVEL = "">
              <MvCOMMENT> API: 5.70 </MvCOMMENT>
          
              <MvFUNCTIONRETURN VALUE = 1>
          </MvFUNCTION>
          
          <MvFUNCTION NAME="Module_Product_BatchEdit_Validate" PARAMETERS="module var" STANDARDOUTPUTLEVEL="">
              <MvCOMMENT> API: 5.70 </MvCOMMENT>
          
              <MvFUNCTIONRETURN VALUE = 1>
          </MvFUNCTION>
          Ray Yates
          "If I have seen further, it is by standing on the shoulders of giants."
          --- Sir Isaac Newton

          Comment


            #6
            Hi Burch,

            After doing some more trial-and-error, I'm getting the impression that there's no way to do what my client wants. It seems like a 3rd-party module can only validate data on the Customers page if its tab is on the screen at the time that the user clicks Update. There doesn't seem to be any way for a module to do extra validation when a user changes a customer's login on the Customers batch-list screen. Is that correct, or am I missing something?

            Thanks again --
            Kent Multer
            Magic Metal Productions
            http://TheMagicM.com
            * Web developer/designer
            * E-commerce and Miva
            * Author, The Official Miva Web Scripting Book -- available on-line:
            http://www.amazon.com/exec/obidos/IS...icmetalproducA

            Comment


              #7
              Originally posted by Kent Multer View Post
              Hi folks,

              My Module_Customer_Validate is already working fine. It's fairly simple; it just has to do some custom validation on the customer's login name, which it gets from g.Customer_Login. It also checks the value of g.Edit_Customer to see whether or not the admin user has entered a new login.

              If I understand you, you want to validate the input from the batch edit screen when an admin user updates a record directly on that screen.

              Since this is done via Ajax, instead of a form submission, Module_Customer_BatchEdit_Validate() Module_Customer_BatchEdit_Update() are never called.

              I think you would have to use the Module_Customer_BatchEdit_Head() function to attach javascript prototype functions to intercept the ajax call and then perform your validation via Javascript. Its possible to do but will take a lot of time working through the JS API.

              Ray
              Ray Yates
              "If I have seen further, it is by standing on the shoulders of giants."
              --- Sir Isaac Newton

              Comment


                #8
                Originally posted by RayYates View Post
                If I understand you, you want to validate the input from the batch edit screen when an admin user updates a record directly on that screen.
                That's right. The client has a lot of custom (non-Miva) software that does after-order processing, and the username (login) is the key for a lot of DB operations. They're about to open a second store, and they want usernames to be unique across both stores, and possibly more stores in the future.

                I wrote a module that allows stores to communicate via HTTP whenever someone creates or changes a username. It's now working fine when customers create or change their own usernames on the Account pages. It works fine when admin users create or change usernames on the "details" page for a single customer. For completeness, I want to get it working on the batch-list page as well; and that's where I'm stuck.

                That's a clever idea, to use BatchEdit_Head() to put some custom JavaScript in there. But it will be tricky, working with no documentation or source code. Are you sure it's feasible? Have you done something like that yourself?

                Thanks --
                Kent Multer
                Magic Metal Productions
                http://TheMagicM.com
                * Web developer/designer
                * E-commerce and Miva
                * Author, The Official Miva Web Scripting Book -- available on-line:
                http://www.amazon.com/exec/obidos/IS...icmetalproducA

                Comment


                  #9
                  Yes it's possible to do, but difficult and very time consuming. The Javascript API is not well documented.

                  This thread may provide you with some insight.
                  http://www.miva.com/forums/forum/des...ike-categories

                  If you can get Ryan (I think that's his name) to chime in, he may be able to point you in the right direction.
                  http://www.miva.com/forums/member/25437-rguisewite

                  Ray Yates
                  "If I have seen further, it is by standing on the shoulders of giants."
                  --- Sir Isaac Newton

                  Comment


                    #10
                    Kent (and Ray),

                    What you are trying to achieve by overriding javascript within the MMBatchList is not advisable. There is an enormous potential to break current and future functionality if you start altering the existing behavior of a list (especially a core list like Customers, and especially when you are not the creator and maintainer of it). If you are dead set on having this functionality from within admin (which seems like what your client wants), I would recommend implementing your own custom batchlist with whatever validation you want baked in (because you'd actually have control over that list -- it would never be touched by anyone but you and those you authorize to alter it -- and it won't interfere with existing code), and have the client use your list instead of the Customers batch list when inline-editing customers in Admin. The link Ray posted contains some good info and other links to more batchlist documentation if that is the route you end up taking. Best of luck (I know it wasn't the answer you were hoping for, and definitely not one I like to give, but I'd much rather everything continue working without issue through future updates than a short term solution that could will likely be a ticking time bomb).

                    Ryan
                    Ryan Guisewite
                    Lead UI Developer / Miva, Inc.
                    www.miva.com

                    Comment


                      #11
                      Hi Ryan, thanks for jumping in.

                      I'm not recommending the JS solution to my client, for all the reasons that have been discussed here. There's no need to create a custom batch-list page, because I can tell the client to just use the details page when they need to change a customer's username.

                      Suppose I was to "downgrade" the module to have an api_ver of 5.00. Would it then be able to access the usual global variables, such as g.Edit_Customer and g.Customer_Login, in the BatchList_Validate function?

                      Thanks --
                      Kent Multer
                      Magic Metal Productions
                      http://TheMagicM.com
                      * Web developer/designer
                      * E-commerce and Miva
                      * Author, The Official Miva Web Scripting Book -- available on-line:
                      http://www.amazon.com/exec/obidos/IS...icmetalproducA

                      Comment


                        #12
                        Ryan

                        I understand where you are coming from, and agree that intercepting the admin JavaScript has the potential to break things going forward.

                        That said, it seems we have lost functionality that was available to us in Miva 5.x. When forms are submitted the xxx_Validate() and xxx_Update() functions were called and we had the opportunity to intercept and influence transmitted data. Now when the Ajax functions are called, the global variables are transmitted as before, but our module functions are never called within admin.mvc. Perhaps this could be addressed in a future update.

                        The only alternative would be to add the ability to subscribe to Admin events the ways we are able to with some of the Store JavaScript events. I've subscribed to attribute machine events on some applications to alter the page behavior. I think most of us old timers would rather do this on the MivaScript side.

                        Kent

                        I don't think downgrading will help you. Your module will never get called


                        Ray Yates
                        "If I have seen further, it is by standing on the shoulders of giants."
                        --- Sir Isaac Newton

                        Comment


                          #13
                          Kent,

                          As Ray said, downgrading your module won't make a difference. The issue here is that starting in Miva Merchant 9.x, the JSON functions called from the batch lists don't call the batch edit feature functions (like vis_custbe, vis_productbe, etc). While there would be some crossover of variables from a single customer, there was much more required by the batch edit features than just a single record (other elements on the page/other tabs, etc) that would not be present and would therefore get wiped out on update.

                          Ray,

                          I'll bring up the possibility of adding in new API functionality (it would have to be new APIs because nothing existing would be a proper fit) for MMBatchLists to bring back the ability to influence validation/updating/deleting/inserting/etc, but I don't know if or when that functionality would be added.
                          Ryan Guisewite
                          Lead UI Developer / Miva, Inc.
                          www.miva.com

                          Comment


                            #14
                            OK, thanks for clarifying that.
                            Kent Multer
                            Magic Metal Productions
                            http://TheMagicM.com
                            * Web developer/designer
                            * E-commerce and Miva
                            * Author, The Official Miva Web Scripting Book -- available on-line:
                            http://www.amazon.com/exec/obidos/IS...icmetalproducA

                            Comment

                            Working...
                            X