locked
Entity title RRS feed

  • Question

  • Hello all, 

    I have an issue about the the title of my opporunities: since I have hidden the field 'Topic' from the form (because I prefered a drop-down list), I do not know how to associate the title of my opportunity to the new field I created.

    Since I'm not a developer, I can't code, so if anybody knows an easy way to fix it, it'll be nice.

    Thanks,

    Sylvain

    Wednesday, May 13, 2015 1:32 PM

Answers

  • Hi,
    you can also do it with a workflow. Right now I don't remember if the label or the value of the optionset get copied (or if it's possible at all to set directly the optionset label to a text field), but if the dropdown items are not so many, you can create if conditions inside your wf to set the right text.

    This will be the no-code solution.

    Using code, a simple JS to copy the label to the topic form will be easy to implement.

    You wrote that you can't code, however do you know how to add JavaScript to the form and the fields?


    My blog: www.crmanswers.net - Rockstar 365 Profile

    • Marked as answer by sylvain_43 Tuesday, May 26, 2015 3:29 PM
    Wednesday, May 13, 2015 3:09 PM

All replies

  • Hi,
    you can also do it with a workflow. Right now I don't remember if the label or the value of the optionset get copied (or if it's possible at all to set directly the optionset label to a text field), but if the dropdown items are not so many, you can create if conditions inside your wf to set the right text.

    This will be the no-code solution.

    Using code, a simple JS to copy the label to the topic form will be easy to implement.

    You wrote that you can't code, however do you know how to add JavaScript to the form and the fields?


    My blog: www.crmanswers.net - Rockstar 365 Profile

    • Marked as answer by sylvain_43 Tuesday, May 26, 2015 3:29 PM
    Wednesday, May 13, 2015 3:09 PM
  • Since I am unsure of your knowledge in CRM I will include the complete noobs guide if you wan´t to go the Javascript way.

    Go to Settings -> Customizations -> Customize the System
    Expand Entities and find the "opportunity" entity, expand it and click Forms
    Double click the the main form to edit it.
    Double click your drop down field click the Details tab and find it´s name (this is needed in the javascript, not the display name)
    Replace in the first line in the function here below "YOURDROPDOWNFIELDNAME" with that name.
    Close the field window so you are back in the forms editor
    Click the "Form Properties" button in the Ribbon.
    Under Form Libraries press the Add Button and in the window that pops up press New to create a new Javascript object
    Give it a name, display name and some description.
    Under type select Script(JScript)
    Under Language select your language.
    Press Save, this should give you an "Text Editor" button next to the type drop down, press that button
    In the Text editor copy the function below (after you replace the field name) press ok/save.
    Then close the create window for the javascript and press the Add button after you find it in the list (Should be selected by default after you close the create window)
    This should take you back to the (Form Properties) window where your new javascript has been added.
    Under Event Handlers in the Control drop down box find the drop down field that you wan´t to copy from and select it
    In the Event drop down make sure OnChange is Selected.
    Make sure to have your new Javascript Selected in the Form Libraries datagrid.
    Press the Add Button in the Event Handlers datagrid (Should be right below Event drop down box)
    This should pop up a new window
    The javascript you created should be selected in the Library drop down.
    In the Function text box set this text "onSetTopicOnChange"
    Make sure the Enabled check box is checked.
    Press Ok to save and close that window
    Press Ok again in the Form properties window.
    Press Save in the Form editor window
    Press Pyblish in the Form editor Window

    This should give you the functionality that you need, this only works though if you are creating opportunities using the forms, not if you import and stuff like that
    I have not tested this javascript but it should work.

    If you are getting errors or this is not working then you can remove the javascript call by doing the following :
    Press the Form Properties button in the Form Editor.
    Under Event Handlers in the Control drop down box find the drop down field that you wan´t to copy from and select it
    Find the function call we just set up Onchange using your new javascript and onSetTopicOnChange.
    Select the line and click Remove
    Click Ok to get back to the Form Editor
    Click Save and then Publish

    You should see in your views if this is working or not when you create a new opportunity.

    function onSetTopicOnChange()
    {
      var selectedText = Xrm.Page.data.entity.attributes.get("YOURDROPDOWNFIELDNAME").getSelectedOption().text;
      Xrm.Page.data.entity.attributes.get("name").setValue(selectedText);
    }


    Halldór Jóhannsson


    Monday, May 18, 2015 2:22 PM
  • Thanks for both of you,

    Finally, I created a workflow which is copying the dropdown field to 'Topic' and so the title is therefore updated.

    Sylvain

    Tuesday, May 26, 2015 3:29 PM