Open a edit page using openCard() CardStateV2.EDIT

Hi Team,

 

I have a detail and on double click on any of the record, it opens the edit page of corresponding detail record record. But, here i want to open the edit page of contact.



Please find the screenshot below for reference.



STEP 1:

 

STEP 2: on Double click it opens the record of the detail as below,

 

STEP 3:  But, i would like to open this contact page edit page (a lookup field with contact base object - is added in the detail object)

 

Please guide me through the process.



Thanks in advance!

 

 



Regards,

Bhoobalan P.

Like 0

Like

6 comments
Best reply

I think putting the following code in the detail schema's methods should achieve what you're trying to do, including navigating back to the right view when you click close:

 

editRecord: function () {
    const activeRow = this.getActiveRow();
    if(activeRow && activeRow.get("UsrRaiser")) {
        const recordId = activeRow.get("UsrRaiser").value;
        const schemaName = "ContactPageV2";
 
        const config = {
            schemaName: schemaName,
            moduleId: this.sandbox.id + schemaName + recordId,
            defaultValues: [],
            operation: "edit",
            id: recordId
        };
 
        this.sandbox.publish("OpenCard", config, [this.sandbox.id]);
    }
}

 

I adapted this code from the openCardInChain method, which is used for opening detail records normally. It overrides the usual detail behaviour when double clicking a record or using the "Edit record" button in the detail menu, and sends an OpenCard message to the edit page, which uses the config to open the record required. Hope this helps.

Dear Bhoobalan,

 

You can do it by modifying the GridArea method for the corresponding EditWindowUSI and IDFieldName. Then add function to analyze in GridAreaOnNotify information about who sent the event. Use the Sender parameter in the event. You can analyze, for example, its USI property, and depending on it, perform the actions needed.

 

Best regards,

Angela

Angela Reyes,

 

Thanks much for the response!



I would like to hear more clarifications on below,

1.What is EditWindowUSI?

2.where does this GridArea method actually present in here (Detail schema)?

3.where to add a function and what function has to be added?

4.what does this GridAreaOnNotify do and what has to be analysed in it?

5.who/what will send/trigger the event and where the event will be sent?

6.What does this sender parameter consists of?



please guide me with distinct steps to acieve this!





what i have managed to find is to override onGridDoubleClick, and stuck to proceed further to achieve my requirement.

{
 "operation": "merge",
  "name": "DataGrid",
  "values": {
  "openRecord": {
           "bindTo": "onGridDoubleClick"
      }
    }
},
 
 
onGridDoubleClick: function() {
 this.console.log("Grid Double clicked");
 var changeToPage = this.getActiveRow().get("UsrFileAttachedToRequest").value;
 
 /* NEED THE LOGIC*/
 
},

 

 

Thanks,

Bhoobalan P.

Bhoobalan Palanivelu,

Hello,

 

Angela provided an example with methods and attributes that are not used in the BaseGridDetail anymore.

 

Please use the method like mine below:

onGridDoubleClick: function(){
            this.console.log("Grid Double clicked");
            var activeRowId = this.get("ActiveRow");
            var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "UsrRequests" });
 				esq.addColumn("UsrChange", "UsrChange");
            	esq.addColumn("Id","Id");
 				esq.filters.addItem(esq.createColumnFilterWithParameter(3, "Id", activeRowId));
 				esq.getEntityCollection(function (result) {
						if (result.success && result.collection.getCount() > 0) {
							var item = result.collection.getByIndex(0);
							var changId = item.get("UsrChange").value;
								var requestUrl = "https://o_drobina.tscrm.com/0/Nui/ViewModule.aspx#CardModuleV2/ChangePage/edit/" + changId;
								this.sandbox.publish("PushHistoryState", {
										hash: requestUrl
									});
							} else {
								this.console.log("No record to open");
							}
						}, this);
 
          },

The logic here is to:

1) Identify the clicked raw in the detail grid (using activeRowId parameter value)

2) Create an ESQ to UsrRequests object (in my example it was an object of a detail that was added to the contact edit page and contained a "Change" lookup column in it)

3) Create a filter for the ESQ so that the Id of the selected UsrRequests record is equal to the active clicked raw of the detail

4) Find an actual "Changes" lookup value Id (using var changId = item.get("UsrChange").value;)

5) Use sandbox.publish to call the edit page for the "Changes" section

 

And also don't forget to connect the onGridDoubleClick method tp the Grid diff (as you did it in your previous post):

{
 			"operation": "merge",
  			"name": "DataGrid",
  			"values": {
  				"openRecord": {
           			"bindTo": "onGridDoubleClick"
      			}
    		}
		}

After the page is refreshed each time the detail record is clicked the connected "Changes" section record edit page will be opened instead of the "UsrRequests" detail edit page:

Also don't forget to replace the https://o_drobina.tscrm.com/0/Nui/ViewModule.aspx#CardModuleV2/ChangePa… link in the requestUrl parameter of getEntityCollection method with the actual link to your website.

 

Best regards,

Oscar

Oscar Dylan,

 

Thanks much for the precious response.

 

Yes, i have tried this below mechanism for transfering/navgating page

this.sandbox.publish("PushHistoryState", {hash: requestUrl});

 

Additionally, i have also tried implementing this below scheme and this too works fine,

			onGridDoubleClick: function () {
				const activeRow = this.getActiveRow();
				var contactID = activeRow.get("UsrRaiser").value;
				var requestUrl = "http://localhost:81/0/Nui/ViewModule.aspx#CardModuleV2/ContactPageV2/edit/" + contactID; 
 
			   if (requestUrl != null) {
window.open(requestUrl, "_Self", "height=" + this.get("WindowHeight") + ",width=" + this.get("WindowWidth"));
			        return false;
			   }
			}, 

 

But the issue is, when i click close on the target page it doesn't take me back to the place where i have performed double click, instead it opens/loads the edit page freshly. (NOTE: though i use Sandbox transfer or window.open i have this issue)



Step 1: Perfoming a double click on detail record,

 

Step 2 : Click close on target page



 

STEP 3 : After close action, i see this page

 

STEP 4 : After close, I want the page to open as below

 

 

Usually, double-click on the row(record) in detail we get the row's Page (no chage in URL) and onClose it takes back to the exact row where the double click action is performed. 

 

Here, i want to achieve the same (Open the target page without chnaging the URL).

 

Please guide me on this!









Regards,

Bhoobalan P.

Bhoobalan Palanivelu,

 

Hello,

 

It seems that it is not possible to do since the application always opens the previous page in case the "Close" button is pressed and it opens the first tab of the previous page always. So the only solution here would be moving the detail to the first tab and using it there.

 

Best regards,

Oscar

I think putting the following code in the detail schema's methods should achieve what you're trying to do, including navigating back to the right view when you click close:

 

editRecord: function () {
    const activeRow = this.getActiveRow();
    if(activeRow && activeRow.get("UsrRaiser")) {
        const recordId = activeRow.get("UsrRaiser").value;
        const schemaName = "ContactPageV2";
 
        const config = {
            schemaName: schemaName,
            moduleId: this.sandbox.id + schemaName + recordId,
            defaultValues: [],
            operation: "edit",
            id: recordId
        };
 
        this.sandbox.publish("OpenCard", config, [this.sandbox.id]);
    }
}

 

I adapted this code from the openCardInChain method, which is used for opening detail records normally. It overrides the usual detail behaviour when double clicking a record or using the "Edit record" button in the detail menu, and sends an OpenCard message to the edit page, which uses the config to open the record required. Hope this helps.

Show all comments