How to call merge function in custom page ?

Hello

How to call merge function in custom page ?

  • Hi Bhavin Patel

    What you want to merge, if you mean arrays then we have predefined array functions in php like array_merge() and array_combine().

    If you want to do it through Studio, do it with concat() function. This will combine any number of strings separated by commas into a single string

    Formula:

    concat($first_name, " ", $last_name)
    

    also

    concat($first_name, " ", $last_name, "is the ",$title, " for testing.")
    

    Path for this is Studio > Module > Fields. check Calculated Value and click on Edit formula

    Hope this Helps

    Best Regards

    S Ramana Raju

  • Hello Ramana Raju Santhana

    Thanks for reply.

    I want to merge duplicate records from my custom page.

    how can i use SugarCRM merge functionality in my page.

  • Hi Bhavin Patel

    You can do it with the help of array_unique() function, it will removes duplicate values from an array. If two or more array values are the same, the first appearance will be kept and the other will be removed.

    Regards

    John

  • Hi Follow John

    can you guide with sample code for this.

    i have 2 ids of contact then how can i open drawer of merge this two record.

  • Hello

    Tevfik Tümer

    Does anyone know how to make it??

  • Hi Bhavin,

    As far as i understand you are trying to merge the models in JavaScript which is on Client side.

    I'm little bit confused in merge operations. How are you going to decide which one will be the value to show in drawer?

    If you say use the second one, then you are not merging replacing it.

    If you are just merging the empty fields, than i would get attributes of first model then go through second model to compare. and using model.set update the one i wanted then use it in the Drawer. Make sense?

    Hope it helps.

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

  • Hi Tevfik Tümer,

    I am wring one code, which is finding the Contacts with Duplicate Name.

    I am displaying those duplicate records in table, selecting few duplicate rows.

    I have database record ids of each duplicate contact.

    How can I open drawer that do merge functionality same as List view?

  • Hi Bhavin,

    Sorry for misunderstanding

    Give a try this code; I didn't test it. Let me know if it doesn't work i can try here really quick.

    var primary = model;
    // or
    // var primary = model.get("id");
    
    
    var models; // <= set here duplicated models
    app.drawer.open({
        layout: 'merge-duplicates',
        context: {
            primary: primary || null,
            selectedDuplicates: models
        }
    });
    

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

  • Hello Tevfik Tümer

    var app = window.parent.SUGAR.App; 
        var primary = '97578173-86b3-b038-3d6b-577f912be9fc';
        var models = '34d6269a-39c9-7e44-9680-5755710e8c0f';
        app.drawer.open({    
            layout:'merge-duplicates',    
            context: {    
                      primary: primary || null,  
                     selectedDuplicates: models 
            }    
        }); 
    

    i m using this code for bwc page but facing error & screen shot is attached.

  • Hi Bhavin,

    Can you give models as model rather than record id?

    This code block what Sugar uses in SugarCRM 7.7.

    Let me know if it doesn't work as well.

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

1 2 3