Steven and toms, I think my question was not clear enough. Let me try to reformulate. I am not trying to update a field during After Save. I am trying to populate a field with a value in the front end only (so Javascript).
Goal:
I'm trying to populate a field on my Contact form.
Procedure:
Users browse Companies. After clicking on a company, along with all the info of the company they have a button to "Create a new contact":
Capture d’écran 2018-07-01 à 12.21.45.png
This button is set up like this (so that it arrives right away on Add a new entry):
Capture d’écran 2018-07-01 à 12.20.47.png
Once they clicked on "Create a new contact" and arrive on the Contact form to add a new contact, I would like to populate the field entreprise_id with the value of the company they were looking at before clicking on "Create a new contact". I'm doing it so far with this JS on the Company form:
Code: Select all
function nuSelectBrowse(e) {
var r = $('#' + e.target.id).attr('data-nu-primary-key');
window.ENTREPRISE_ID = r;
nuForm(nuGetProperty('form_id'), r);
}
And this JS on the Contact form:
Code: Select all
if (nuFormType() == 'edit') {
$("#contact_entreprise_id").val(window.ENTREPRISE_ID).change();
nuHasNotBeenEdited();
}
(This code was suggested by toms on works well).
The problem is that it only works when the user is browsing already existing companies (because of the function nuSelectBrowse()). So when the user creates a new company and saves it, and clicks on "Create a new contact", the function nuSelectBrowse() is not executed, so there is no entreprise_id populated in the Contact form.
So my question was: how can I populate this entreprise_id field on the Contact form after a new company is created and the button "Create a new contact" is clicked?
You do not have the required permissions to view the files attached to this post.