Creating a new Smart Guide record with API is encountering an issue

Hello,

I am currently encountering an issue with the Smart Guide. Specifically, I have implemented a button within the Leads module's Edit Dropdown menu. Upon clicking this button, a custom API is invoked, which is designed to create a new record in the Smart Guide Module(DRI_Workflows) by providing all the necessary values to the newBean function.

However, I have observed that this functionality is not working consistently across all leads. For some leads, the following error is returned with the random id:

{"error": "not_found", "error_message": "Could not find Smart Guide Stages with 6a8efc00-f7e0-11ee-a6fc-0a1db36945e2"}

Here is the code snippet of newBean:

$bean = BeanFactory::newBean('DRI_Workflows');
$bean->name = $name;
$bean->date_entered = date("Y-m-d H:i:s");
$bean->date_modified = date("Y-m-d H:i:s");
$bean->modified_user_id = $current_user->id;
$bean->created_by = $current_user->id;
$bean->assigned_user_id = $current_user->id;
$bean->team_id = 1;
$bean->team_set_id = 1;
$bean->lead_id = $args['lead_id'];
$bean->available_modules = '^Leads^,^Opportunities^';
$bean->state = 'in_progress';
$bean->assignee_rule = 'stage_start';
$bean->target_assignee = 'current_user';
$bean->dri_workflow_template_id = $templateId;
$id = $bean->save();

Thanks in advance