Forum Discussion
Hello,
You can temporarily store the value of this inside of another variable before you open your dialog. This should allow you to access it inside of your callback after the dialog returns.
// Store the value of the context item
var self = this;
wnd.ArasModules.Dialog.show('iframe', param).promise.then(callback);
After this, you can access the context item in your callback through the variable you've defined instead of this.
function callback(res) {
if (res) {
var id_1 = res[0];
var id_2 = res[1];
self.setProperty("MyProperty", id_1);
self.apply();
}
}
As an additional note, you almost never need to define a new Innovator object inside of a Method. From a client-side method, you can access an Innovator object from most contexts by using aras.IomInnovator. This admittedly shouldn't have any impact on functionality, but it's slightly more memory efficient to reference the existing object.
Chris
Christopher Gillis
Aras Labs Software Engineer
How do I bring the "self" variable back after the dialog returns? When i set a debugger statement in the callback function and check what variables I have, I can't find the variables from before the dialog was called. My action and method are acting on a relationship item, and it seems like the context after the dialog is the parent item of the relationship instead of the relationship item which is the context before the dialog is opened.
I had some success with aras.IomInnovator, I used:
function callback(res) {
if (res) {
var sel_id = res[0];
var rel_id = res[1];
var inn = aras.IomInnovator;
var rel_item = inn.getItemById("RelationshipItemtype",rel_id);
var sel_item = inn.getItemById("RelatedItemtype",sel_id);
rel_item.setProperty("related_item_property",sel_item);
rel_item.apply();
}
}
I can see that rel_item and sel_item are successfully defined in the debugging mode, but the property isn't being updated.
- RickP7 years agoIdeator I
It actually seems to be working now! I just didn't realize since the relationship grid didn't update to show it until I did an empty search, I guess I just need to figure out how to make the method run an empty search as well.
- christopher_gillis7 years agoNew Member
Hi Rick,
You can take advantage of another function of the aras object to refresh the grid. You can call aras.uiReShowItem(item_id, item_id); in order to refresh the parent item. Since you said that the this variable seems to be referencing the parent item in the callback, you might be able to accomplish this refresh like so:
aras.uiReShowItem(this.getAttribute("id"), this.getAttribute("id"));
Note that this will depend on what the actual value of this is.
In regards to your question about referencing the self variable, I was able to reference this variable just by calling self inside of the callback. This was a test I ran in 11.0 SP15 using the ArasModules.Dialog.show function. This variable reference might be different if you are using another version of Aras Innovator or a different function for opening your dialog.
Chris
- RickP7 years agoIdeator I
I'm on v11 SP12 so maybe it's different, the window is being called like this:
var topWnd = top.aras.getMostTopWindowWithAras();
var wnd = topWnd ? topWnd : window;
wnd.ArasModules.Dialog.show('iframe', param).promise.then(callback);Thanks for the help anyways!