SuiteCRM's specialized duplicate validation feature is experiencing issues with saving or updating data

Hello there!

I have implemented a custom validation on my SuiteCRM to check if the First Name, Last Name, and Mobile number already exist. However, I am facing an issue where the data does not save or update after the validation process. Below are the codes from my view.edit.php:

$javascript = <<<'EOT'
    <script type="text/javascript" language="JavaScript">
    function customJavascriptDuplicateValidation(thisview)
    {
        var firstname = document.getElementById('first_name').value;
        var lastname = document.getElementById('last_name').value;
        var mobile = document.getElementById('mobile_number').value;
        var birthday = document.getElementById('birthday').value;
        var email = document.getElementById('email_c').value;
        var location = document.getElementById('location_code').value;
        var consent = document.getElementById('consent_timestamp_date').value;
        var salutation = document.getElementById('salutation').value;
        
        $.post('index.php?entryPoint=checkDuplicateCustomers', { first_name: firstname, last_name: lastname, mobile_number: mobile }, function(data)
        {
            if (data == 'exists') {
                $('#error_firstname_msg').html('<strong style="color:red;"> &#x2717; Already Used</strong>');
                $('#error_lastname_msg').html('<strong style="color:red;"> &#x2717; Already Used</strong>');
                $('#error_mobile_msg').html('<strong style="color:red;"> &#x2717; Already Used</strong>');
                return check_form('EditView');
            }else if (data == 'unique'){
                $('#error_firstname_msg').hidden;
                $('#error_lastname_msg').hidden;
                $('#error_mobile_msg').hidden;
                if(firstname != '' && lastname != '' && mobile != '' && birthday != '' && email != '' && location != '' && consent != '' && salutation != ''){
                    return check_form('EditView');
                }else{
                    return check_form('EditView');
                }
            }else{
                $('#error_firstname_msg').hidden;
                $('#error_lastname_msg').hidden;
                $('#error_mobile_msg').hidden;
                return check_form('EditView');
            }
        });
        
    }
    </script>
    EOT;

I also made changes to the save button in editviewdefs.php:

$viewdefs['Accounts']['EditView']['templateMeta']['form']['buttons'][0] = array(
'customCode' => '<input title="Save" accesskey="a" class="button primary" onclick="var _form = document.getElementById(\'EditView\'); _form.action.value=\'Save\'; if(customJavascriptDuplicateValidation(\'EditView\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="Save" id="SAVE">',);

The default validation works when you click on SAVE. https://i.sstatic.net/zUZTl.png

The custom validation is also working when you click on SAVE: https://i.sstatic.net/gxJW7.png

https://i.sstatic.net/OFiAF.png

However, even after entering all the required fields and unique customer information, the data is not being saved.

I suspect the issue lies in my custom JavaScript code. When I place the code snippet below outside the $.POST function, the data gets saved, but the custom duplicate validation does not work when all fields in the condition are not null/empty:

if(firstname != '' && lastname != '' && mobile != '' && birthday != '' && email != '' && location != '' && consent != '' && salutation != ''){
                     SUGAR.ajaxUI.showLoadingPanel();
                    return check_form('EditView');
                }

Answer №1

Ignore the previous information. I resolved the issue by incorporating the following code:

                SUGAR.ajaxUI.showLoadingPanel();
                var _form = document.getElementById('EditView');
                _form.action.value='Save';
                SUGAR.ajaxUI.submitForm(_form);
                return check_form('EditView'); 

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible for me to invoke a div within a different component?

I am facing a challenge with a large div component. <div id='download> ..... </div> My goal is to incorporate this same component into a Paper within a Modal. <Modal> <Box sx={style} > <Paper elevation ...

Error in JSON access permissions while using AJAX call to Webmethod in ASP.NET webforms with jquery Datatables

My current project involves implementing server-side processing for jQuery Datatables.NET in an ASP.NET webforms test application. Here is the code I am using: $(document).ready(start); function start(){ $('#PersonsTable').DataTable({ ...

I encountered an issue when sending a PATCH request via Hoppscotch where the request body content was returned as 'undefined', although the username and ID were successfully

const express = require("express"); const app = express(); const path = require("path"); let port = 8080; const { v4: uuidv4 } = require('uuid'); app.use(express.urlencoded({extended: true})); app.set("views engine", ...

developing a custom modal using a button in a React project with Material UI

Hello everyone, I have a question regarding React. I am fairly new to React and need some assistance with adding a new function that creates a Modal. I want to call this function onClick when the add icon is pressed (line 43). Any help would be appreciated ...

The error notification is not appearing in the correct location

I've been troubleshooting my jQuery error function for hours now (including the success function). I'm struggling to figure out how to display an error message only below the button that I click. To help clarify my issue, I've created a JSFi ...

The Vuetify v-btn within the v-bottom-navigation remains in an active state even when it has not

I am encountering an issue with a button in the bottom navigation bar of my Vuetify application. I have set up several buttons as routes in Nuxtjs, which become active when the corresponding page is visited. However, there is a button in the bottom nav bar ...

It seems that you're facing an issue with the react-native-git-upgrade tool. The error message

I encountered issues while attempting to upgrade using react-native-git-upgrade. One of the first problems I faced was similar to what was described in https://github.com/facebook/react-native/issues/11578. Unfortunately, none of the solutions mentioned i ...

Differentiating between mouseenter and tap events: What's the key?

When a mouseenter event is present, touch-enabled devices will activate this event when the user taps on the element. Is there a way to differentiate between an actual physical mouse entering and a simulated tap (which resembles a mouse enter)? ...

Live AJAX inquiries in progress

Is there a way to track the number of active AJAX requests in jQuery, Mootools, or another library similar to Prototype's Ajax.activeRequestCount? I am looking for a method that can be used across different libraries or directly through XMLHttpRequest ...

Converting information from a model into individual variables

I'm a newcomer to typescript and angular, and I've been attempting to retrieve data from firebase using angularfire2. I want to assign this data to variables for use in other functions later on. I am accustomed to accessing object members using d ...

Can we dynamically add an identical DOM structure by clicking a button using jQuery?

I currently have ten text fields within a single div. I am interested in including another set of ten text fields with the same name, class, and id. Is there a way to recycle the existing DOM structure mentioned above, or will I need to generate and add t ...

Is it possible to convert the text.json file into a jQuery animation?

Looking to extract information from text.json and integrate it with my jquery.animation(). My goal is similar to the one demonstrated here. Instead of using "data" attributes like in that example, I want to parse the text based on the "ID" property as a k ...

Is there a way to stop a for-in loop within a nested forEach function in JavaScript?

I am facing a situation with nested loops for (var key in params) { if (Array.isArray(params[key])) { params[key].every(function(item) { let value = something(item.start, item.end); if (value === item.start || value == item.end) { ...

Error in ReactJS: TypeError - Trying to convert undefined or null as an object

Here is the affected code with Typescript errors in local. The component name is correct: {template.elements.map((element: TemplateElementModel, i) => { const stand = roomStands?.find( (stand: ExhibitorModel) => stand.standN ...

Troubleshooting a Node.js problem with variable scope

I'm working on a nodejs route that downloads a URL as an mp3 using npm-youtube-dl. I have a download directory being monitored with chokidar for new files, and once a file is added, I save the file link. After the download completes, a function is cal ...

Tips for modifying the background color of an individual page in Ionic 3 and above

https://i.stack.imgur.com/t2mDw.pngI am just starting with Ionic and I'm attempting to modify the CSS of a single page by changing the background color to something different, like green, for example. I know that I can make global changes, but in this ...

Switch out text and calculate the frequency of letters in a given string

I have a string that looks like this: "061801850010300-09/A/B". My goal is to replace all "/" with "-" and also change "A" to "1" and "B" to "2". My objective is to assign each letter in the alphabet a numerical value - for example, A as 1, B as 2, C as 3 ...

Inquiring about the rationale behind using `jquery.ui.all.css` specifically

I'm curious about the impact of jquery.ui.all.css on Tabs As soon as I remove it, <link rel="stylesheet" href="jquery/dev/themes/base/jquery.ui.all.css"> My tabs stop functioning. Here's my query: What exactly does the jquery.ui.all.cs ...

How can I make the arrows work on a secondary slider with EasySlider1.7?

I finally managed to get 2 sliders working on my page after reading through several other tutorials. However, I am facing an issue with the Prev & Next arrows on the second slider as they don't seem to work properly. I inherited this page from someon ...

Using a Component's Variable in Another Component in React Native

Hello there! Thank you so much for offering your help. I have a component called PlayerWidget and would like to utilize its state variable isPlaying value in the AlbumHeader Component. Here is the code for the PlayerWidget: import React, { useContext, use ...