ASP Page, New Workflow Record and the correct procedure to set the record into the workflowinstance

Hello,

I am using CRM 7.3 SP1 (hotfix 1) and there is a new workflow set up in the Case entity.

The asp page is creating a new record and inserting the correct stage for the New record and inserting the tracking for the case workflow but, the workflow instance is not creating.

How would I resolve this in the asp page?

The asp page has the correct coding to set the workflow into the workflow state eg:

record=CRM.CreateRecord("cases");
if( false )
record.SetWorkFlowInfo("Issue Workflow", "Issue Logged");

And yet the workflow actions that appear are for the standard Case workflow and there is no record added into the workflowinstance table for the corresponding case record created.

Would it be better to add a table level script for postinsert ?

Thanks for any guidance here.

Cheers.

Penny

  • 0

    Hi Michele,

    Thanks for your advice. I changed it to true and the correct workflow and actions are set on the initial screen.. it appears to be a success and the workflowinstance record is created. Checking the tracking tab though, there is no entry in the case progress table. When I use if (false), the case progress table is updated with the tracking of the stage but the default case workflow actions (incorrect workflow) appear and the workflowinstance record is not created. I must have to create a record in the caseprogress table as well. I haven't had much success with this in the past so I will see what I can find on the community site. Cheers Michele.

  • 0

    Penny:

    Based on the above code, I think you need to change the second line from if(false) to if(true). If that does not work for you, please post the rest of the page code as there may be something in another area of the code that is causing the workflow instance not to be created.

    Hope that helps! Michele

  • 0

    Hi Michele,

    Thank you for taking the time to assist me! I will give this a go and see how I get on.

    I must admit, the case status box normally does this for me and the detail is being pulled through into the status, stage, user etc. as per the asp page (and I also have the actions in the workflow New stage set for these as well - to be double sure!). The rest of the workflow behaves itself and the case progress table is updated along with the workflow instances. I will report back Michele. Cheers!

  • 0

    Well, I set the stage and status in the asp page and set the if to false and the case progress table is populated. Back to square one though as the workflow is going back to the default workflow for case and not picking up the correct workflow.

    I will set it back to if (true) and leave the case progress table issue for now.

    Thanks so much for your assistance Michele.

  • 0

    Penny:

    Based on my experience, you have to set the stages separately. Meaning, the creation of workflow does not set the stage on the cases table for you. Therefore, the Case Progress is not correct because the Progress table is a "mirror" of the Case table. When you set the stage on the case table, it will automatically update the progress table.

    Try this...

    ///////////////////////////////////////////////////////

    record=CRM.CreateRecord("cases");

    if( false )

    record.SetWorkFlowInfo("Issue Workflow", "Issue Logged");

    record.case_stage = 'IssueLogged';

    record.case_status = 'ThisIsMyStatus';

    //////////////////////////////////////////////////////

    Replace ThisIsMyStatus with whatever that initial status should be.

    As the case moves through the workflow, the case_stage and case_status along with the progress table will be updated by the values you place in workflow.

    Hope this helps! Michele

  • 0

    Penny

    This is some example code to show how a Case record can be created, and have its workflow set and the first tracking record created in the caseprogress table.

    var myRecord = CRM.CreateRecord("cases");

    myRecord.case_primarycompanyid = 28;

    myRecord.case_primarypersonid = 30;

    myRecord.case_assigneduserid = 1;

    myRecord.case_channelid = 5

    myRecord.case_description = "Hello World";

    myRecord.case_source = "Jeff";

    myRecord.case_status = "In Progress";

    myRecord.case_stage = "Logged";

    myRecord.SetWorkflowInfo("Case Workflow", "Logged");

    myRecord.SaveChanges();

    var myRecord2 = CRM.CreateRecord("caseprogress");

    myRecord2.case_assigneduserid = 1;

    myRecord2.case_channelid = 5

    myRecord2.case_status = "In Progress";

    myRecord2.case_stage = "Logged";

    myRecord2.case_caseid = myRecord.case_caseid;

    myRecord2.SaveChanges();

  • 0

    Hi Jeff,

    Thank you for the example.

    I will try your format for creating a caseprogress record and see how I go.

    Best regards,

    Penny