How to get the record Id In LWC Quick Action

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ม.ค. 2025

ความคิดเห็น • 8

  • @pradeepaksks-bx8ip
    @pradeepaksks-bx8ip 6 หลายเดือนก่อน +1

    How can we perform dml operation and rest callout in a single transaction from lwc

    • @salesforcein5minutes
      @salesforcein5minutes  6 หลายเดือนก่อน

      First make the dml and check if id is not null and then make immediately callout to the system if its not null

    • @awesomekj5812
      @awesomekj5812 6 หลายเดือนก่อน +1

      @@salesforcein5minutes won't you get PENDING TRANSACTION error ? I think standard practice is to always do callout first and then do the DML or just do the callout in future method.

    • @pradeepaksks-bx8ip
      @pradeepaksks-bx8ip 6 หลายเดือนก่อน +1

      @@salesforcein5minutes in LWC controller Execution will not wait until response received from the callout, and we need to handle the response received and need to convert it to json Object and then pass the returned value to the apex method imperatively, May be I think we need to make use of async and await or promise chain in this scenario, but I am not sure.

    • @salesforcein5minutes
      @salesforcein5minutes  6 หลายเดือนก่อน

      @@awesomekj5812 yeah but we check id is there or not and after that we make a callout, basically if id was available that means record creation is done successfully and that operation is done

    • @salesforcein5minutes
      @salesforcein5minutes  6 หลายเดือนก่อน

      @@pradeepaksks-bx8ip you can also use platform. Events for such cases