# Apexコード / Visualforceページの起動

カスタムアクション機能を利用することで、Salesforce上で開発したApexコードおよびVisualforceページをSheetから呼び出すことも可能です。

## Visualforceページの起動

Visualforceページを呼び出すには、「URLを開く」アクションからページURLに以下の形式でURLを入力します。

`/apex/{Visualforceページの名前}`

管理パッケージに含まれるVisualforceページなど、名前空間を持っている場合には、以下の形式でURLを入力します。

`/apex/{名前空間プレフィックス}__{Visualforceページの名前}`

アクションの詳細設定からパラメータ名を適切に指定します。VisualforceページのApexコントローラからは以下のコードでパラメータ値を取得することが可能です。

```
ApexPages.currentPage().getParameters().get('id');
```

## Apexコードの起動

Apexで記述したカスタムのロジックをSheetから呼び出したい場合は、一旦フローを介して起動するのが最も効果的です。カスタムアクションでのフローの起動方法は「[フローの起動](/mashmatrix-sheet/ja/customization/start_visual_workflow.md)」を参照してください。

フローからApexの呼び出しを行うには`@InvocableMethod`を実装した静的メソッドを持つApexクラスを用意する必要があります。詳しくはSalesforceのヘルプおよび開発者資料を参考にしてください。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mashmatrix.com/mashmatrix-sheet/ja/customization/start_custom_apex_visualforce.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
