Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

How to concat (1st character of 1st field + 1st character of 2nd field + 3rd field value ) set in Product Id field of the Product form ?

Posted on by 40

 Hi Expert ,

   I want to set some concat value  of 3 fields in Product Id field of the Product form. I have two option type field 1)  Plan 2) Payment Type . Now  below is the example of concat value :

            Product Id =          concat(1st character of Plan + 1st character of PaymentType  + Product Name)

  Whenever user change Plan or Payment type value Product Id concat value also will be changed real time.

 How it can be done ?

Thanks

Surajit Kundu

   

  • surajitinsync Profile Picture
    surajitinsync 40 on at
    RE: How to concat (1st character of 1st field + 1st character of 2nd field + 3rd field value ) set in Product Id field of the Product form ?

    Thanks clofy it's working.

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: How to concat (1st character of 1st field + 1st character of 2nd field + 3rd field value ) set in Product Id field of the Product form ?

    Hi surajitinsync,

    You could refer to my JS code.

    function Concatenatefields(executionContext) {
        var formContext = executionContext.getFormContext();
        var plan = formContext.getAttribute("new_plan").getText();
        var payment =formContext.getAttribute("new_payment").getText();
        var productName = formContext.getAttribute("new_productname").getValue();
        var test ="";
        if (plan != null) {
            test = test   plan;
            if (payment != null) {
                test = test   payment;
            }
            if (productName != null) {
                test = test   productName;
            }
        }
        else if (payment != null) {
            test = test   payment;
            if (productName != null) {
                test = test   productName;
            }
        }
        else if (productName != null) {
            test = test   productName;
        }
        formContext.getAttribute("productnumber").setValue(test);
    }
    

    In Opportunity form, run the function at OnChange event of Plan, Payment and ProductName field.

    Test result:

    2642.png

    Regards,

    Clofly

  • surajitinsync Profile Picture
    surajitinsync 40 on at
    RE: How to concat (1st character of 1st field + 1st character of 2nd field + 3rd field value ) set in Product Id field of the Product form ?

    Hi Andrew,

      Thanks for your reply. I want to do it in JS. Fields details below :

    Name

    Schema

    Display

    Type

    FieldType

    name

    name

    Name

    Single Line of Text

    Simple

    new_plan   

    new_plan   

    Plan

    Option Set

    simple

    crf50_paymentoption_g

    crf50_paymentoption_g

    Payment Option

    Option Set

    simple

    productnumber

    productnumber

    Product Id

    Single Line of Text

    Simple

        Product Id   =   1st character of Plan field value   +  1st character of Payment Option  field value +  '-'  + Name  field value

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to concat (1st character of 1st field + 1st character of 2nd field + 3rd field value ) set in Product Id field of the Product form ?

    Hello,

    Is it JS or C#? What types of fields? A little more context could help.

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