C
C
Carinogatto2021-02-20 22:36:17
JavaScript
Carinogatto, 2021-02-20 22:36:17

How can I change the event for the arrow function from form B24 initialization to the submit event of this form?

There is an article in the Bitrix24 help. An example of working with the code of new CRM forms
The article says that you can set the values ​​of fields that are not placed on this form.
To do this, just place the code before the form itself:

<script> window.addEventListener('b24:form:init', (event) => { let form = event.detail.object;  if (form.identification.id == 792) { form.setProperty("param1", "1"); form.setProperty("city", "Kaliningrad"); } }); </script>

I'm interested form.setProperty("param1", "1");
Instead of "1" I want to pass the result of filling out another form on the site (step by step quiz).
I figured out how to pass a variable or the result of a function. I just initially mistakenly thought that the value is substituted at the time of submitting the Bitrix form.
It turned out that at the time of loading the page and the form itself.
This means that the variable in this case is empty, because it is filled with text when the visitor answers the quiz questions.

Now I understand that I need to bind the execution of the event to another event, not 'b24:form:init'
I don't know how to do it, because it's an arrow function, but I still don't understand its essence.
Screenshot of a piece of code with the Bitrix24 form:
60378ba28229d759774904.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question