WORKFLOW: Create DocumentFolder and asign it to a parent folder.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danieldids
    Junior Member
    • Dec 2018
    • 15

    WORKFLOW: Create DocumentFolder and asign it to a parent folder.

    Hi there, happy AdvancedPack customer here.

    I've created a workflow that creates a new folder when an account of a given type is created. Code bellow:

    $clientFolderId = record\create(
    "DocumentFolder",
    "name", targetEntity\attribute("name")
    );


    $parentFolderId = record\findOne(
    "DocumentFolder","createdAt","asc",
    "name=","Arquivo Clientes"
    );

    record\update(
    'DocumentFolder',$clientFolderId,
    'parent',$parentFolderId
    );


    Code in green is working, orange is not. What I need is to have the newly created folder inside the other one (called "Arquivo Clientes", portuguese BR).

    This is being done using formula because DocumentFolder doesn't appear in the drop down on Actions.
  • danieldids
    Junior Member
    • Dec 2018
    • 15

    #2
    So funny when it happens... I've found the error just after posting.


    // THIS CODE HERE WAS OK
    $parentFolderId = record\findOne(
    "DocumentFolder","createdAt","asc",
    "name=","Arquivo Clientes"
    );

    // THIS WAS NOT: parentId should be used, not just parent as in the original post
    record\update(
    'DocumentFolder',$clientFolderId,
    'parentId', $parentFolderId
    );

    Comment

    • Vadym
      Super Moderator
      • Jun 2021
      • 345

      #3
      Hi!

      We’re glad your problem is solved.

      All the best, Daniel!

      Comment

      Working...