Community
Showing results for 
Search instead for 
Do you mean 
Reply

Pulled out Notes of Company records only

Accepted Solution Solved
New Member
Posts: 7
Country: India
Accepted Solution

Pulled out Notes of Company records only

[ Edited ]

I am writing code to extract Notes from ACT. I have successfully pulled out Person's Notes from ACT! ,but failed to extract notes which are available for Company records only. Is there any way to extract notes which are available for Company records only?


Accepted Solutions
Solution
Accepted by rkain (Copper Super Contributor)
‎09-25-2015 03:20 AM
Copper Super Contributor
Posts: 52
Country: United_Kingdom

Re: Pulled out Notes of Company records only

[ Edited ]

Hello mann16,

 

The method I've written below should do what you need:

 

public List<Note> getCompanyNotes(Act.Framework.ActFramework fwk)
{
    //CREATE A NEW LIST OF HISTORY ITEMS
    List<Note> noteList = new List<Note>();

    try
    {
        //GET A LIST OF COMPANIES
        CompanyList companyList = fwk.Companies.GetCompanies(null);

        //LOOP THOUGH EACH COMPANY
        foreach (Company company in companyList)
        {
            AggregationType aggregationType = AggregationType.All;
            NoteList cNoteList = fwk.Notes.GetNotes(null, company, aggregationType, null, false);
            foreach (Note note in cNoteList)
            {
                //ADD HISTORY ITEM TO HISTORYLIST (hl)
                noteList.Add(note);
            }
        }
        //RETURN THE LIST
        return noteList;
    }
    catch (Exception)
    { 
        //RETURN THE LIST 
        return noteList;
    }
}

 

Usage Example

 

List<Note> notes = getCompanyNotes(oActFwk);
foreach (Note note in notes)
{
    MessageBox.Show(note.NoteText);
}

I hope this helps.

 

Kins regards,

 

 

Russell 

 

View solution in original post


All Replies
Solution
Accepted by rkain (Copper Super Contributor)
‎09-25-2015 03:20 AM
Copper Super Contributor
Posts: 52
Country: United_Kingdom

Re: Pulled out Notes of Company records only

[ Edited ]

Hello mann16,

 

The method I've written below should do what you need:

 

public List<Note> getCompanyNotes(Act.Framework.ActFramework fwk)
{
    //CREATE A NEW LIST OF HISTORY ITEMS
    List<Note> noteList = new List<Note>();

    try
    {
        //GET A LIST OF COMPANIES
        CompanyList companyList = fwk.Companies.GetCompanies(null);

        //LOOP THOUGH EACH COMPANY
        foreach (Company company in companyList)
        {
            AggregationType aggregationType = AggregationType.All;
            NoteList cNoteList = fwk.Notes.GetNotes(null, company, aggregationType, null, false);
            foreach (Note note in cNoteList)
            {
                //ADD HISTORY ITEM TO HISTORYLIST (hl)
                noteList.Add(note);
            }
        }
        //RETURN THE LIST
        return noteList;
    }
    catch (Exception)
    { 
        //RETURN THE LIST 
        return noteList;
    }
}

 

Usage Example

 

List<Note> notes = getCompanyNotes(oActFwk);
foreach (Note note in notes)
{
    MessageBox.Show(note.NoteText);
}

I hope this helps.

 

Kins regards,

 

 

Russell 

 

New Member
Posts: 7
Country: India

Re: Pulled out Notes of Company records only

Hello Russel,

 

Thanks for your help. But still it is not working as I am expecting.

 

FYI, my expectation as below.

1) Company  'Test Company' present in ACT

2) Contact 'Test Contact' is present in ACT which is link with 'Test Comany'

3) Suppose I have added One note for Contact 'Test Contact' and one more note only for Company 'Test Company' , then while pulling out Company notes It is pulling out Contact's Note also.

In above scenario I want to pull out Only one note which is related to Company only.

 

Hope you have understood what I am trying to do.

 

Copper Super Contributor
Posts: 52
Country: United_Kingdom

Re: Pulled out Notes of Company records only

[ Edited ]

Hi mann16,

 

The only thing that seperates a company note from a conact note is whether or not the note has contacts linked. See the screenshot below:

 

computer.png

 

So to acheive what you want you should just be able to modify my code by wrapping this:

 

//ADD HISTORY ITEM TO HISTORYLIST (hl)
noteList.Add(note);

 With this:

 

if (note.ContactCount < 1)
{
    //ADD HISTORY ITEM TO HISTORYLIST (hl)
    noteList.Add(note);
}

 

I hope this gives you what you need.

 

Regards,

 

 

Russell 

 

New Member
Posts: 7
Country: India

Re: Pulled out Notes of Company records only

Hello Russell,

 

Thank you very much. 

 

Now it is working perfectly. Smiley Happy 

 

Ragards,

Manoj Naik.

Copper Super Contributor
Posts: 52
Country: United_Kingdom

Re: Pulled out Notes of Company records only

Not a problem at all :-)