How to add multiple records using write records?

Certified Senior Developer

Hi all,

I have a requirement of creating multiple tasks at a time when a new case is added based on a dropdown field.

I have used a!writerecords function and have achieved creating multiple records at a time but I have to related the newly created multiple records with a single ID.

I tried it with local variable, tried with expression rule and tried with a rule input of integer field.

I have saved new primary key of the case in a local variable and later saved it in integer rule input using a!save in button. In interface level it was showing that the value is added but the it is not being saved in database.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    A few things:

    1. I'm assuming the case is not written to DB before you are trying to write tasks. If there's a FK constraint added in on rtkl Id column in task table in DB that can cause the write record function to error.

    2. I agree, it's better to write in PM and write in sequence: 1. Update new case 2. Write tasks for the new case

    If you don't want to follow this practice:

    1. Configure onSuccess and onFailure parameters to know what the error might be.

    2. The way to calculate the caseDatanum isn't fool proof. You can only query 5000 records. What if your record size is more than 5000? Better query only last record (using sort) and then take max value. As mentioned above, this would only work if there's no FK constraint added in the table.

Reply
  • 0
    Certified Lead Developer

    A few things:

    1. I'm assuming the case is not written to DB before you are trying to write tasks. If there's a FK constraint added in on rtkl Id column in task table in DB that can cause the write record function to error.

    2. I agree, it's better to write in PM and write in sequence: 1. Update new case 2. Write tasks for the new case

    If you don't want to follow this practice:

    1. Configure onSuccess and onFailure parameters to know what the error might be.

    2. The way to calculate the caseDatanum isn't fool proof. You can only query 5000 records. What if your record size is more than 5000? Better query only last record (using sort) and then take max value. As mentioned above, this would only work if there's no FK constraint added in the table.

Children
No Data