Community
Showing results for 
Search instead for 
Do you mean 
Reply

CurrentCompany does not refresh

Accepted Solution Solved
Copper Super Contributor
Posts: 18
Country: United_Kingdom
Accepted Solution

CurrentCompany does not refresh

[ Edited ]

HI,

 

I am facing an issue with the Current Company value not having the correct value. As an example I have two companies currently- Company A and Company B.

I am trying to get value of fields based on the current company name. This works for the first time the company detailed view is loaded and I get the name as Company A using the code ActApplication.Instance.ApplicationState.CurrentCompany.ToString(); .

 

However, when I click on Company B the ActApplication.Instance.ApplicationState.CurrentCompany.ToString(); still returns the name of the previous company - Company A. I have tried to refresh the view, etc but nothing works.

 

Now if I switch back to Company A, ActApplication.Instance.ApplicationState.CurrentCompany.ToString();  gives me the value as Company B.

 

Can someone let me know what the issue is here and what would be the solution.

 

Thanks

 

Satyajit


Accepted Solutions
Solution
Accepted by topic author satyajit_singh
‎09-25-2015 03:20 AM
Copper Super Contributor
Posts: 18
Country: United_Kingdom

Re: CurrentCompany does not refresh

[ Edited ]

Hi,

 

My application fetches and populates dropdown boxes on basis of certain fields. To capture record changing events I am using currency manager and positionchanged and itemchanged events.

 

I use ActApp.ApplicationState.CurrentCompany to get the current company record data. However there is an issue with ActApp.ApplicationState.CurrentCompany not updating values when I click on another company within detailed company view (by clicking on another company on the left hand tree).

 

Another new issue is that If I am on a company record currently and then I click on New button to add a new company and then cancel the add and return back to the company record that I was on previously on, in this case ActApp.instance.ApplicationState.CurrentCompany.Name will have a null value. 

Any suggestions how to overcome this problem.

View solution in original post


All Replies
Employee
Posts: 1,163
Country: USA

Re: CurrentCompany does not refresh

Hello Satyajit,

 

I could not reproduce this. I used some extremely basic code:

 

Company myComp = ActApp.ApplicationState.CurrentCompany;
MessageBox.Show(myComp.Name);

This code would fire when I clicked on a menu item that I've created. Are you doing this in the company detail view? This will not return the selected company in the list view.

Matthew Wood
Act! SDK Support
Community Moderator
Copper Super Contributor
Posts: 18
Country: United_Kingdom

Re: CurrentCompany does not refresh

Hi Matthew,

 

Yes I am doing in this in the company Detail view. For reason unkown it does pick up the company name in the Item changed event however on clicking or moving to the other company it does not refresh the company name (still shoes the new company name).

 

Currently I have overcome this by doing a refresh of the instance.

 

However I have used the code below (as you have suggested) in another project and it works.

 

Many Thanks

 

Satyajit

Solution
Accepted by topic author satyajit_singh
‎09-25-2015 03:20 AM
Copper Super Contributor
Posts: 18
Country: United_Kingdom

Re: CurrentCompany does not refresh

[ Edited ]

Hi,

 

My application fetches and populates dropdown boxes on basis of certain fields. To capture record changing events I am using currency manager and positionchanged and itemchanged events.

 

I use ActApp.ApplicationState.CurrentCompany to get the current company record data. However there is an issue with ActApp.ApplicationState.CurrentCompany not updating values when I click on another company within detailed company view (by clicking on another company on the left hand tree).

 

Another new issue is that If I am on a company record currently and then I click on New button to add a new company and then cancel the add and return back to the company record that I was on previously on, in this case ActApp.instance.ApplicationState.CurrentCompany.Name will have a null value. 

Any suggestions how to overcome this problem.