1

What is the best way of getting fields from grants available as tokens for mail/PDF-merge?

No native tokens? Not available in form processor extension?

2 Answers 2

1

If the tokens for grants are not available in core (which I can imagine) and appartently the data-processor tokens extension does not work with them either, the option you have left is to create an extension that adds them as custom tokens.

1
0

I had this need recently, and found CiviGrant doesn't have native token support.

However, it took only a few minutes with the SearchKit Tokens extension to create grant tokens.

Install that extension, then you can go to Search menu » SearchKit and press the Import button. Paste in the text below to get tokens for all your core fields.

If you want to add tokens for custom fields:

  • Go to Search » SearchKit
  • Click the pencil icon next to Grant Tokens.
  • On the Select Fields tab, add any new fields you'd like.
  • Click on the grant display.
  • Click Add/Remove Fields and select the field(s) you just added.
  • Scroll down in the list and set a Token Label. That's the name as they will appear in the token browser.
[
  [
    "SavedSearch",
    "save",
    {
      "records": [
        {
          "name": "Grant_Tokens",
          "label": "Grant Tokens",
          "api_entity": "Grant",
          "api_params": {
            "version": 4,
            "select": [
              "id",
              "grant_type_id:label",
              "financial_type_id:label",
              "amount_granted",
              "amount_requested",
              "application_received_date",
              "contact_id",
              "decision_date",
              "currency:label",
              "money_transfer_date",
              "rationale",
              "grant_due_date",
              "grant_report_received",
              "status_id:label",
              "amount_total"
            ],
            "orderBy": [],
            "where": [],
            "groupBy": [],
            "join": [],
            "having": []
          }
        }
      ],
      "match": [
        "name"
      ]
    }
  ],
  [
    "SearchDisplay",
    "save",
    {
      "records": [
        {
          "name": "Grant_Tokens_Tokens_1",
          "label": "grant",
          "saved_search_id.name": "Grant_Tokens",
          "type": "tokens",
          "settings": {
            "columns": [
              {
                "type": "field",
                "key": "id",
                "dataType": "Integer",
                "label": "ID"
              },
              {
                "type": "field",
                "key": "grant_type_id:label",
                "dataType": "Integer",
                "label": "Grant Type"
              },
              {
                "type": "field",
                "key": "financial_type_id:label",
                "dataType": "Integer",
                "label": "Financial Type"
              },
              {
                "type": "field",
                "key": "amount_granted",
                "dataType": "Money",
                "label": "Amount Granted"
              },
              {
                "type": "field",
                "key": "amount_requested",
                "dataType": "Money",
                "label": "Amount Requested"
              },
              {
                "type": "field",
                "key": "application_received_date",
                "dataType": "Date",
                "label": "Application Received Date"
              },
              {
                "type": "field",
                "key": "contact_id",
                "dataType": "Integer",
                "label": "Contact ID"
              },
              {
                "type": "field",
                "key": "decision_date",
                "dataType": "Date",
                "label": "Decision Date"
              },
              {
                "type": "field",
                "key": "currency:label",
                "dataType": "String",
                "label": "Currency"
              },
              {
                "type": "field",
                "key": "money_transfer_date",
                "dataType": "Date",
                "label": "Grant Money Transfer Date"
              },
              {
                "type": "field",
                "key": "rationale",
                "dataType": "Text",
                "label": "Grant Rationale"
              },
              {
                "type": "field",
                "key": "grant_due_date",
                "dataType": "Date",
                "label": "Grant Report Due Date"
              },
              {
                "type": "field",
                "key": "grant_report_received",
                "dataType": "Boolean",
                "label": "Grant Report Received"
              },
              {
                "type": "field",
                "key": "status_id:label",
                "dataType": "Integer",
                "label": "Grant Status"
              },
              {
                "type": "field",
                "key": "amount_total",
                "dataType": "Money",
                "label": "Total Amount"
              }
            ]
          }
        }
      ],
      "match": [
        "saved_search_id",
        "name"
      ]
    }
  ]
]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.