How to show a single button in Activity Section Page for adding new Task

Hi All,



By default in the Calendar section page, it shows only one button "Task" which maps to the edit page of Activity Type - "Task" :







I have added a new edit page of Activity type "Schedule" and overridden the Button Diff to change the caption.



As a result of this, it shows all the edit pages in the Test button DropDown as you can find in the below image. The above code returns all the editPage when count greater than 1.







How to map the "Schedule" edit page button to the Test and remove all the other buttons and the dropdown feature. Similar to how by default "Task" edit page button gets mapped to Task button.



Kindly help me how to implemet this.



Regards and Thanks,

Adharsh S

Like 0

Like

4 comments

Hi Adharsh, 



We  checked your problem and came up with the following solutions: 



1. You may turn off 'Values of the type Lookup' that you don't want to use in your drop-down menu. In this way you'll get just one button to choose. But please be careful because all you previous activities will be shown due to the page that is opened upon clicking on the chosen button. (In your case - Schedule).

 







2. The second way you can implement it using code (in case option 1 was applied all the changes from option 1 should be reverted before applying the next code): 



Bellow you may find the example: 

 define("ActivitySectionV2", [], function() {

  return {

    entitySchemaName: "Activity",

    details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,

    diff: /**SCHEMA_DIFF*/[

      {

                    "operation": "merge",

                    "name": "SeparateModeAddRecordButton",

                    "parentName": "SeparateModeActionButtonsLeftContainer",

                    "propertyName": "items",

                    "values": {

                        "controlConfig": {

                            "menu": {

                                "items": {

                                    "bindTo": "EnabledEditPages",

                                    "bindConfig": {

                                        "converter": function(editPages) {

                                            if (editPages.getCount() > 1) {

        // Add some condition here

        // Add filter to display only specific pages

        var result = editPages.filter(function(page) {

            return page.get("SchemaName") === "UsrActivity1Page"; // Display only activities

        });

        return result;

    } else {

        return null;

    }

                            

                                        }

                                    }

                                }

                            }

                        }

                    }    

                },

    ]/**SCHEMA_DIFF*/,

    methods: {}

  };

});



P.S. 

 



In this case you still have a little drop down menu (with one option): UsrActivity1Page - the object page that will be displayed. In this case all your activities remain the same. 



Hopefully it will help you! 



Best Regards, 



Bogdan L

Bogdan Lesyk,



The above code is really helpful.

As you mentioned a little drop-down menu with one option is shown.



But the use case is to show only one button("NEW TASK") similar to what we have in OOTB which is mapped to the Activity Type - "TASK".



Even though we are adding a new edit page, I don't want to have a separate button for it.



I just need to show the OOTB button "NEW TASK" and ignore all others, similar to what you see in the below image.







It will be really helpful, as how to implement this.



Regards and Thanks,

Adharsh S

Adharsh,

 

Then you need to use the first option Bogdan proposed and also override the initAddRecordButtonParameters method on the ActivitySectionV2:

 

initAddRecordButtonParameters: function() {
				var caption = this.get("Resources.Strings.AddRecordButtonCaption");
              	this.set("AddRecordButtonCaption", caption);
            }

And specify "New task" as a value of the "AddRecordButtonCaption" localizable string in the ActivitySectionV2.

 

Best regards,

Oscar

Oscar Dylan,



We are using two EditPages one is OOTB - "Activity Type - TASK" which is used to create tasks through UI. That's where we need the OOTB button with activity type as "TASK".

Apart from this, we are creating a new custom edit page for Another Activity Type. We don't need to show the button in UI.



If we follow the first option proposed by Bogdon, the business case will get failed.



I need to use both edit pages in the Activity section. But it's enough to show only the OOTB button ("NEW TASK").



Is there a way to implement this.



Regards and Thanks,

Adharsh S

Show all comments