Action

Search Craft

Posted by FlohGro, Last update about 2 years ago

UPDATES

about 2 years ago

added note on how to retrieve the space id

show all updates...

about 2 years ago

added note on how to retrieve the space id

about 2 years ago

usage of credential to store the space id which shoudl be used

about 3 years ago

fixed typo in description

created by @FlohGro / more on my Blog

Search Craft

With this action you can open the search in Craft prefilled with the content of the current draft in a configurable space

[Configuration]

If you don’t wan’t to use the (any of my) action for different Craft spaces there is no configuration needed. When you first run any of my Craft actions it will ask you to store the space id of your Craft space. This is a one time action and you don’t need to do it for any other of my Craft actions you install.

To retrieve your spaceId just copy the deeplink of any document in that space (refer to the Craft Support Page when you don’t know how to do that). Paste the copied id into a draft and you will se a link similar to this: “craftdocs://open?blockId=[the block id]&spaceId=[the spaceId]” - find the character combination “[the spaceId]” after the “spaceId=” and copy it and paste it into the prompt of this action.

To use these actions with different spaces you need to duplicate the action for each space you want to use it. I recommend to e.g. add a suffix to the action name to describe the space for which you configure it.

The action uses Drafts possibility to store credentials to distinguish different spaces. When you duplicate the action for another space you have to change the name of the credential. Therefore you need edit this line const spaceIdCredentialName = "CraftDocumentSpace" in the script step of the action and change the CraftDocumentSpace to something different (e.g. describe the space in a suffix like „CraftDocumentSpacePersonal" or „CraftDocumentSpaceWork“. If you use several of my Craft actions you should use the same credential name in all of them.

[Usage]

Use this action to search for the content of the current draft in the configured space.


If you find this useful and want to support me you can

Buy Me A Coffee</a*created by @FlohGro / my CraftBlog*

Create Craft Note

This action creates a new Document in Craft in a configurable space.

[Configuration]

If you don’t want to use the (any of my) action for different Craft spaces there is no configuration needed. When you first run any of my Craft actions it will ask you to store the space id of your Craft space. This is a one time action and you don’t need to do it for any other oof my Craft actions you install.

To retrieve your spaceId just copy the deeplink of any document in that space (refer to the Craft Support Page when you don’t know how to do that). Paste the copied id into a draft and you will se a link similar to this: “craftdocs://open?blockId=[the block id]&spaceId=[the spaceId]” - find the character combination “[the spaceId]” after the “spaceId=” and copy it and paste it into the prompt of this action.

To use these actions with different spaces you need to duplicate the action for each space you want to use it. I recommend to e.g. add a suffix to the action name to describe the space for which you configure it.

The action uses Drafts possibility to store credentials to distinguish different spaces. When you duplicate the action for another space you have to change the name of the credential. Therefore you need edit this line const spaceIdCredentialName = "CraftDocumentSpace" in the script step of the action and change the CraftDocumentSpace to something different (e.g. describe the space in a suffix like „CraftDocumentSpacePersonal" or „CraftDocumentSpaceWork“. If you use several of my Craft actions you should use the same credential name in all of them.

[Usage]

When you made notes during a meeting or while reading something and you decide to move the notes to Craft, simply run this action and it will create and open the new document in Craft. The markdown formatting will not be changed and applied to each created block in Craft.

If you want to use the actions for different spaces in Craft just follow the instructions above.


If you find this useful and want to support me you can

Buy Me A Coffee>

Steps

  • script

    // created by @FlohGro
    
    // optional configuration of the spaceIdCredentialName - only necessary if you want to use the same action for different Craft Spaces
    const spaceIdCredentialName = "CraftDocumentSpace"
    
    
    let spaceID = getCraftSpaceIdToUse();
    
    let content = draft.processTemplate("[[draft]]")
    
    const baseURL = "craftdocs://opensearch?"
    
    var cb = CallbackURL.create()
    cb.baseURL = baseURL
    cb.addParameter("spaceId",spaceID)
    cb.addParameter("query",content)
    cb.waitForResponse = false
    cb.open()
    
    
    function getCraftSpaceIdToUse() {
        let credential = Credential.create(spaceIdCredentialName, "Credential to store the spaceId of the space you want to use in Drafts.\ninsert your spaceId into the TextField below. \n\nNOTES: \n- this is a one time action, you don't need to do it everytime\n- Multiple spaces are currently not supported with this spaceId credential helper");
        credential.addTextField("spaceId", "spaceId");
        if (credential.authorize()) {
            return credential.getValue("spaceId");
        } else {
            let errorStr = "failed storing / retrieving space Id with credential"
            app.displayErrorMessage(errorStr);
            context.fail(errorStr);
            console.log(errorStr);
            return false;
        }
    }
    

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.