Skip to content
Discussions/App Development/How to do Interactions of two choice from different templateForum ↗

How to do Interactions of two choice from different template

App Development5 posts209 viewsLast activity Feb 2023
AK
akshayvchavhOP
Feb 2023

Hi there ,I am working on two choices which are in 2 different template. How can I make changes in of one choice from one template to another choice of another template and change the parameters.
For eg :- my choice from Invoice template and want to change the status.

A_
a_putkov
Feb 2023

@akshayvchavh
I’m afraid I’m not following what you’re looking to do. Would you mind elaborating? A specific example would probably be most helpful.

AK
akshayvchavh
Feb 2023

Here I created UpdatePOVStatus and UpdatePOStatus ,and now I am getting error as Update failed due to fetch of an inactive contract

Code :-
controller operator can
nonconsuming VInvSetHospital : ContractId Invoice
with
invcid : ContractId Invoice
hospital: Party
useremail: Text
username: Text
do

          let payment_term = foldl(\paymentterm invoiceVendorTerm ->
                      if invoiceVendorTerm.hospital == hospital
                      then paymentterm <> invoiceVendorTerm.auto_payment_hospital
                      else paymentterm
                      ) "" admindetails.invoice_term_setting

          (newinvCid, invoicecontract) <- exercise invcid SetInvoiceHospital with 
                            payment_term = Some payment_term
                            vendor_ach_info= vendordetails.ach_info
                            vendor_address = Some vendordetails.vendoraddress
          addNewLogEvents (operator, vendor, (Some hospital), SendInvoice, 
            (InvoiceLogEntry with invData = invoicecontract), useremail, username, (invcid /= newinvCid))
          
          (poCid, po) <- findPO (operator, hospital, vendor, invoicecontract.invoicedata.invpurchaseorderid)
          (povCid, pov) <- findPOV (operator, hospital, vendor, invoicecontract.invoicedata.invpurchaseorderid)
          -- update po, pov status
          _ <- if isSome poCid then do
              exercise (fromSome poCid) UpdatePOStatus with newpostatus = InvoiceReceived
              pure()
            else pure()

          _ <- if isSome povCid then do
              exercise (fromSome povCid) UpdatePOVStatus with newpostatus = InvoiceSent
              pure()
            else pure()
          
          return (newinvCid)

@a_putkov

RI
rikotacards
Feb 2023

The error is as mentioned, “failed due to fetch of an inactive contract”

It looks like you are exercising a choice VInvSetHospital, and you pass in the invcid, I don’t think you’ve copied and pasted the part where you fetch the invoice contract.

or it can be “newpoststatus = InvoiceReceived” But I’m not sure based on this snippet. But the overall issue is, you’re using a contract that has probably been archived or has not yet been created yet.

AK
akshayvchavh
Feb 2023

Thanks @rikotacards ,I will try it.

← Back to Discussions