> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Guides

> How to work with sales guides in CRMScript.

<Note>
  This feature requires a **Sales Premium** license or the **Core** plan.
</Note>

## Stages

### NSSelectableMDOListItem\[] GetStages()

```crmscript! theme={null}
NSListAgent listAgent;
NSSaleTypeEntity type = listAgent.GetSaleTypeEntity(1);
NSSelectableMDOListItem[] stages = type.GetStages();

for(Integer i = 0; i < stages.length(); i++) {
  printLine(stages[i].GetId().toString() + " | " + stages[i].GetName() + "\t Rank " + stages[i].GetRank().toString());
}
```

<Note>
  The ID and rank of a stage are not necessarily identical!
</Note>

### Get stages without using the sale type

```crmscript theme={null}
NSMDOAgent a;

NSMDOListItem[] saleprob = a.GetList("saleprobability",false,"",false);

for(Integer i = 0; i < saleprob.length(); i++) {
  printLine(saleprob[i].GetId().toString() + "\t" + saleprob[i].GetName());
}
```

### Bool GetIsAutoAdvance()

```crmscript! theme={null}
NSListAgent listAgent;
NSSaleTypeEntity type = listAgent.GetSaleTypeEntity(1);

printLine("This sale will auto advance: " + type.GetIsAutoAdvance().toString());
```

## Suggested activities

### List available suggestions

```crmscript! theme={null}
SearchEngine se;
se.addFields("SuggestedAppointment", "SuggestedAppointment_id,name,saleTypeStageLinkId");
print(se.executeTextTable());
```

### Create follow-up from suggestion

All you need is 3 IDs, and then calling `CreateDefaultAppointmentEntityFromSaleSuggestion()` will do the magic for you!

* ID of the suggested appointment
* ID of the sale
* ID of the owner (associate)

```crmscript theme={null}
NSAppointmentAgent appointmentAgent;
NSAppointmentEntity newAppointment = appointmentAgent.CreateDefaultAppointmentEntityFromSaleSuggestion(3,4,false,5);
newAppointment = appointmentAgent.SaveAppointmentEntity(newAppointment);
```

<Tip>
  You can also [create documents from suggestions][2].
</Tip>

### Create a suggestion and link it to a stage

You can also create your own blueprints and load default values into them.

This example creates a suggestion called *Read specification* with a duration of 2 hours. It then links it to an **NSSaleTypeStageLink** with ID 1.

```crmscript! theme={null}
NSAppointmentAgent appointmentAgent;
NSSuggestedAppointmentEntity myBlueprint = appointmentAgent.CreateDefaultSuggestedAppointmentEntity();

myBlueprint.SetName("Read specification");

TimeSpan t;
t.set(0, 0, 2, 0, 0);
myBlueprint.SetDuration(t);

NSSaleTypeStageLink link;
link.SetProbId(1);
link.SetSaleTypeId(1);
link.SetSaleTypeStageLinkId(1);
myBlueprint.SetSaleTypeStageLink(link);

myBlueprint = appointmentAgent.SaveSuggestedAppointmentEntity(myBlueprint);
```

<Tip>
  If you re-run the query for SuggestedAppointment, you'll find the new blueprint and its ID in the result.
</Tip>

## Reference

### SaleTypeStageLink

| Field                 | Description       |
| :-------------------- | :---------------- |
| SaleTypeStageLink\_id | ID                |
| saleType\_id          | Link to sale type |
| stageId               | Link to stage     |
| rank                  | sort order        |

### SuggestedAppointment

| Field                    | Description                               |
| :----------------------- | :---------------------------------------- |
| SuggestedAppointment\_id | ID                                        |
| name                     | name of blueprint shown in guide          |
| rank                     | sort order                                |
| saleTypeStageLinkId      | anchor for sale guide items               |
| task\_id                 | type of the suggested appointment         |
| daysFuture               | when the appointment should be scheduled  |
| duration                 | in minutes                                |
| text                     | The suggested text of the new appointment |

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

[2]: ../../../../database/tables/suggestedappointment


## Related topics

- [Edit or deactivate project guide](/en/project/admin/edit-project-guide.md)
- [Edit or deactivate a sales guide](/en/sale/admin/edit-sales-guide.md)
- [ProjectGuide](/en/api/archive-providers/reference/projectguide.md)
- [SaleGuide](/en/api/archive-providers/reference/saleguide.md)
- [Create a new project guide](/en/project/admin/create-project-guide.md)
- [Create a new sales guide](/en/sale/admin/create-sales-guide.md)
- [ProjectGuideAppointment](/en/api/archive-providers/reference/projectguideappointment.md)
