Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

JavaScript to detect duplicate record and show alert msg

(0) ShareShare
ReportReport
Posted on by 365
Here my field is lookup fieldpastedimage1601755671660v1.png
function PMSrecord(executionContext) {
    debugger
    var formContext = Context.getFormContext();
    var wtype = formContext.getAttribute("new_preventivemaintenanceschedule");
    if (wtype != null) {
        wtypeValue = wtype.getValue();
        if (wtypeValue != null) {
            var entityTypeCode = wtypeValue[0].type;
            var entityTypeName = wtypeValue[0].entityType;
            var entityId = wtypeValue[0].id.replace("{""").replace("}""");
            var entityText = wtypeValue[0].name;
            if (entityText == entityText) {
                
                formContext.ui.setFormNotification("Duplicate Record Found.""INFO"); 
            }
            else
            {formContext.ui.setFormNotification("Create Record.""INFO"); }
            
           
        }
        
    }
}
 
  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    Temmy Wahyu Raharjo 2,914 on at
    RE: JavaScript to detect duplicate record and show alert msg

    Hi unbeatable,

    You need to retrieve the records based on your criteria using WebApi.retrieveMultipleRecords. If you find any data, then u need to set formNotification like what u did earlier.

    Good luck!

  • unbeatable Profile Picture
    unbeatable 365 on at
    RE: JavaScript to detect duplicate record and show alert msg

    I want to write Javascript code for detecting duplicate record and the field is a lookup field for detecting duplicate record

  • unbeatable Profile Picture
    unbeatable 365 on at
    RE: JavaScript to detect duplicate record and show alert msg

    I want to write code, please help with Javascript

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: JavaScript to detect duplicate record and show alert msg

    Hi,

    why don't you use OOB Duplicate detection rule to achieve your requirement instead of writting custom code?

    www.advantage.co.uk/.../

    if (entityText == entityText) {

                   formContext.ui.setFormNotification("Duplicate Record Found.", "INFO");

               }

    Above code does not make sense. You are comparing the same variable. please tell your exact requirement so that we can help you?

    Please mark my answer verified if i were helpful

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans