mibuso.com

Microsoft Business Solutions online community
It is currently Tue May 21, 2013 10:53 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: How to lookup to company B.customer from Company A
PostPosted: Fri Jul 20, 2012 12:19 pm 
Offline

Joined: Fri Oct 25, 2002 1:13 pm
Posts: 135
hi there,
i would like to know what is the method to look up to CompanyB.customer from Company A.

My coding is as below, but the lookup giving the Customer within the Company A.
Please suggest any method to do the lookup the data to other company book.

---------------------------------------------------------------------------------
Cust.CHANGECOMPANY("OtherCompanyName");

CustCard.SETTABLEVIEW(Cust);
CustCard.SETRECORD(Cust);
CustCard.LOOKUPMODE(TRUE);
IF CustCard.RUNMODAL = ACTION::LookupOK THEN BEGIN
CustCard.GETRECORD(Cust);
message(Cust."No.");
END;
---------------------------------------------------------------------------------

Thank you.

regards,
rachel


Top
 Profile  
 
 Post subject: Re: How to lookup to company B.customer from Company A
PostPosted: Fri Jul 20, 2012 1:19 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Tue Jul 19, 2005 4:49 pm
Posts: 3836
Location: Olst
Country: Netherlands (nl)
The only way to achieve this is using a temporary record and store the values in that first.

Then make sure that the form in not editable.

_________________
Mark Brummel | Freelance Dynamics NAV (Navision) Developer
Author of the book : Microsoft Dynamics NAV 2009 Application Design

MY BLOG : http://www.brummelds.com


Top
 Profile E-mail WWW  
 
 Post subject: Re: How to lookup to company B.customer from Company A
PostPosted: Fri Jul 20, 2012 1:53 pm 
Offline

Joined: Fri Mar 30, 2007 12:50 pm
Posts: 211
Location: Nieuwe Niedorp
Country: Netherlands (nl)
Hi Rachel,

There are two other ways to do this.

1.

Don't run the form as a variable but with an id.
Code: Select all
Cust.CHANGECOMPANY(OtherCompanyName);
IF FORM.RUNMODAL(FORM::"Customer List", Cust) = ACTION::LookupOK THEN
  MESSAGE(Cust."No.");


2.

Do the ChangeCompany also in the OnOpenForm trigger.
You first have to set the companyname with a function in the form.

------------------------------------
Code: Select all
Cust.CHANGECOMPANY(OtherCompanyName);
CustList.SetOtherCompany(OtherCompanyName);
CustList.SETTABLEVIEW(Cust);
CustList.LOOKUPMODE(TRUE);
IF CustList.RUNMODAL = ACTION::LookupOK THEN BEGIN
  CustList.GETRECORD(Cust);
  MESSAGE(Cust."No.");
END;


------------------------------------

Code: Select all
Form - OnOpenForm()
IF OtherCompanyName <> '' THEN
  CHANGECOMPANY(OtherCompanyName);

_________________
Reijer Molenaar
Freelance NAV Developer
Object Manager
TVblik


Top
 Profile E-mail  
 
 Post subject: Re: How to lookup to company B.customer from Company A
PostPosted: Fri Jul 20, 2012 5:05 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Tue Aug 14, 2001 7:01 am
Posts: 5315
Location: Prague
Country: Czech Republic (cz)
reijermolenaar wrote:
Hi Rachel,

There are two other ways to do this.

1.

Don't run the form as a variable but with an id.
Code: Select all
Cust.CHANGECOMPANY(OtherCompanyName);
IF FORM.RUNMODAL(FORM::"Customer List", Cust) = ACTION::LookupOK THEN
  MESSAGE(Cust."No.");




:thumbsup: Interesting, I never tried it this way, I have always done it the second way you describe changing company directly on the form from a function.

What happens to flow fields drill downs subforms etc when you do it this way? (Yeah I know I could try, but it's easier to just ask :mrgreen: )

_________________
David Singleton
Dynamics NAV Freelancer
Dynamics Book
Go-Live International


Top
 Profile E-mail WWW  
 
 Post subject: Re: How to lookup to company B.customer from Company A
PostPosted: Sat Jul 21, 2012 9:37 am 
Offline

Joined: Fri Mar 30, 2007 12:50 pm
Posts: 211
Location: Nieuwe Niedorp
Country: Netherlands (nl)
I didn't tested it but I'm pretty sure that the changecompany doesn't apply to anything else but the REC of the form. So even the values in the flowfields are showing 'wrong' amounts.

_________________
Reijer Molenaar
Freelance NAV Developer
Object Manager
TVblik


Top
 Profile E-mail  
 
 Post subject: Re: How to lookup to company B.customer from Company A
PostPosted: Sat Jul 21, 2012 10:32 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Tue Jul 19, 2005 4:49 pm
Posts: 3836
Location: Olst
Country: Netherlands (nl)
I would at least make a special Customer Card form for this, preferably non-editable. People will start using the lookups and menuitems and find out they work in another company.

The temporary table will make sure that you don't start making changes that you don't expect.

_________________
Mark Brummel | Freelance Dynamics NAV (Navision) Developer
Author of the book : Microsoft Dynamics NAV 2009 Application Design

MY BLOG : http://www.brummelds.com


Top
 Profile E-mail WWW  
 
 Post subject: Re: How to lookup to company B.customer from Company A
PostPosted: Sat Jul 21, 2012 3:12 pm 
Offline

Joined: Sat Jun 05, 2010 10:36 am
Posts: 58
Location: Ahmedabad
Country: India (in)
Hello Mark / reijermolenaar,

I found it is interesting topic & thanks to reijermolenaar that sharing this great trick =D> =D> =D> .

I did some R & D related this.

1. Flow Field's Value is displayed Correct, It get whole record from other company.
2. Look Up : Displayed other company's data correctly, BUT user can insert & edit data of other company which is wrong.
3. Drill Down : Displayed other company's data correctly, BUT user can insert & edit data of other company which is wrong.
4. Go to Card : Displayed the record of current company's data if available,
if not available then also it is display on card with same no. of other company's no. with all field blank.
if we insert something there then system insert that record in current company.
if we not make change then nothing changed.
5. Editable Fields : Dangerous, User can make any changes.

Thanks & Regards,
Purvesh Maisuria.


Top
 Profile E-mail  
 
 Post subject: Re: How to lookup to company B.customer from Company A
PostPosted: Sat Jul 21, 2012 5:22 pm 
Offline

Joined: Fri Mar 30, 2007 12:50 pm
Posts: 211
Location: Nieuwe Niedorp
Country: Netherlands (nl)
Thanks Purvesh.

I didn't know that flowfields were respecting the changecompany.
Learning everyday something new.
Even in the weekend! :mrgreen:

_________________
Reijer Molenaar
Freelance NAV Developer
Object Manager
TVblik


Top
 Profile E-mail  
 
 Post subject: Re: How to lookup to company B.customer from Company A
PostPosted: Sat Jul 21, 2012 11:10 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Tue Jul 19, 2005 4:49 pm
Posts: 3836
Location: Olst
Country: Netherlands (nl)
I didn't know about the flowfields either. That's why I love the community.

Reading the testresults I can only emphasise to please make a different cardform for this and block anything that can cause unexpected behaviour.

Changecompany has been discussed many times weather or not to make it smarter or not.

_________________
Mark Brummel | Freelance Dynamics NAV (Navision) Developer
Author of the book : Microsoft Dynamics NAV 2009 Application Design

MY BLOG : http://www.brummelds.com


Top
 Profile E-mail WWW  
 
 Post subject: Re: How to lookup to company B.customer from Company A
PostPosted: Sun Jul 22, 2012 4:12 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Thu Jan 02, 2003 6:37 pm
Posts: 7931
Location: Howell, MI
Country: United States (us)
I knew that flowfields follow CHANGECOMPANY and that they display the right values, I was actually shocked at the time that it worked, but very happy because I had to do extensive programming around some multicompany development that I was doing at the time.

As far as using the normal Card form that definitely NOT OK, because everything else will show the company that you're logged into. If you really want to have a Card form that looks exactly the same, and acts exactly the same, you will have to create a new form and program the crap out of it.

You have absolutely no idea how much work this is....

After all these years, people still do not take proper precautions when advising others about working with CHAMGECOMPANY.... ](*,)

_________________
Daniel Rimmelzwaan
MVP - Dynamics NAV


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: