Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Do validations only allow true or false
#1
I was asked to do a validation where the salesorder shipping address needs to match the account shipping address. Now that's easy enough, but I was also asked to provide the option to overwrite the currect salesorder address with the address from the account when there is no match. Do we have some option to fire a custom function when a validation fails or is it just true of false? And if it is, would it be a good idea to allow custom 'ontrue' and 'onfalse' handlers? I could work on that.
Reply
#2
I had a quick look which escalated into a little over half an hour to implement this change

https://github.com/tsolucio/corebos/comm...dd653bcbe0

that permits us to use the same functionality we have in the custom file validations, where you can return CONFIRM and FUNCTION


Code:
<map>

  <originmodule>
    <originname>Accounts</originname>
  </originmodule>
  <fields>
    <field>
      <fieldname>accountname</fieldname>
      <validations>
        <validation>
          <rule>contains</rule>
          <restrictions>
          <restriction>mex</restriction>
          </restrictions>
<message>%%%FUNCTION%%%yourfunction%%%PARAMS%%%{field},lbl</message>
        </validation>
      </validations>
    </field>
  </fields>
</map>

your custom function has to have this profile:

(edit_type, formName, action, callback, params)

I see that FUNCTION is not documented here:

https://corebos.com/documentation/doku.p...validation

it should be
Joe
TSolucio
Reply
#3
there is an example here: http://blog.corebos.org/blog/developerblock

give it a try and let me know how it goes
Joe
TSolucio
Reply
#4
Very nice, let me try and figure this out.
Reply
#5
(08-07-2020, 01:34 AM)joebordes Wrote: there is an example here:  http://blog.corebos.org/blog/developerblock

give it a try and let me know how it goes

About the class code example in the blog, you left the line
PHP Code:
$smarty $this->getViewer(); 
in there.
Reply
#6
I think that is intentional to show readers that they have access to that object without creating it again (less memory and setup overhead)
Joe
TSolucio
Reply
#7
Ah, thought it didn't live on the parent but that's where it comes from then

(08-07-2020, 01:34 AM)joebordes Wrote: there is an example here:  http://blog.corebos.org/blog/developerblock

give it a try and let me know how it goes

Can't get this to work. I've tried logging my 'process' function to the fatal log, but it never seems to be called. Neither does it cause an error. I created the business action for the developerblock but it doesn't seem to do anything.
Reply
#8
I tried it. can you share some maps to see what you have done?
Joe
TSolucio
Reply
#9
you just need to create a JS function and return the message in the indicated format
Joe
TSolucio
Reply
#10
I'm not sure I understood the instructions correctly then. Judging by the blogpost I thought I didn't have to create a map. I thought a developerblock of type 'presave' would just do the work, returning the name of the JS function to be executed along with parameters.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)