• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Edit
Show / Hide Table of Contents

Stakeholders

•
Version: 10
Some tooltip text!
• 2 minutes to read
 • 2 minutes to read

Organizations as stakeholders

The contact_id is the ID of the organization and the person_id is 0.

Note

We're working with the contact database table here. Not to be confused with the company table!

Look up a company based on its domain

Company c;
c.findFromDomain("superoffice.com");
print(c.getValue("name"));

View company info

Integer stakeholderId = 1;
NSSaleAgent saleAgent;
NSSaleStakeholder stakeholder = saleAgent.GetSaleStakeholder(stakeholderId);

if (stakeholder.GetPersonId() != 0) {
  printLine("Name: " + stakeholder.GetContactName() + "\t Role: " + stakeholder.GetStakeholderRoleName());
}

Read more about working with organizations.

Individuals as stakeholders

The contact_id is the ID of the organization (as before) but the person_id is 0.

Note

We're working with the person database table here. Not to be confused with the contact or associate tables!

Look up a person based their email address

Customer c;
printLine(c.findFromEmail("jean-luc@superoffice.com").toString());

View person info

Integer stakeholderId = 2;
NSSaleAgent saleAgent;
NSSaleStakeholder stakeholder = saleAgent.GetSaleStakeholder(stakeholderId);

if (stakeholder.GetPersonId() != 0) {
  printLine(stakeholder.GetFirstname() + " " + stakeholder.GetLastname());
}

Read more about working with persons.

List all stakeholders of a sale

Get from agent:

Integer saleId = 4;
NSSaleAgent saleAgent;
NSSaleStakeholder[] stakeholderList = saleAgent.GetSaleStakeholders(saleId);

for(Integer i = 0; i < stakeholderList.length(); i++) {
  print(stakeholderList[i].GetSaleStakeholderId().toString() + "\t");
  printLine("Contact: " + stakeholderList[i].GetContactId().toString() + "\t Person: " + stakeholderList[i].GetPersonId().toString());
}

Get from current sale:

NSSaleEntity sale;
NSSaleStakeholder[] stakeholderList = sale.GetSaleStakeholders();

Create a stakeholder

NSSaleStakeholder stakeholder = saleAgent.CreateDefaultSaleStakeholder();
stakeholder.SetContactId(1);
stakeholder.SetSaleId(4);
stakeholder.SetStakeholderRoleId(1);
stakeholder = saleAgent.SaveSaleStakeholder(stakeholder);

List available roles

SearchEngine se;
se.addFields("StakeholderRole", "StakeholderRole_Id,name");
print(se.executeTextTable());

Add new stakeholder to a sale

NSSaleAgent saleAgent;
NSSaleEntity sale = saleAgent.GetSaleEntity(4);

// Pull up the stakeholder we just created
NSSaleStakeholder newStakeholder = saleAgent.GetSaleStakeholder(1);

NSSaleStakeholder[] stakeholderList = sale.GetSaleStakeholders();
stakeholderList.pushBack(newStakeholder);

sale.SetSaleStakeholders(stakeholderList);

sale = saleAgent.SaveSaleEntity(sale);

Reference

NSSaleStakeholder

Field Get method Description
salestakeholder_id GetSaleStakeholderId() ID
stakeholderrole_id GetStakeholderRoleId() Role
sale_id GetSaleId() parent sale
contact_id GetContactId() contact (person or org)
person_id GetPersonId() ID of person OR 0 if an org

For a complete list of fields, see the database reference.

In This Article
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top