Welcome to Portal

?Unknown\pull-down

Welcome to Zoho Cares

Bienvenido a Soporte de Zoho

Search our knowledge base, ask the community or submit a request.

Hi

I am sorry to bring this on here but I am really stuck.
So I have a form that lists all our products we sell with a field for Purchased Stock and Sold Stock.

I have another form for Purchase of Products, which when filled out, updates the Purchased Stock Field, this works

I have 2 forms for selling,
Form B - 1 Looks up product (This is a hidden form)

2nd one for Actual selling, will have client name address details and a subform to Form B to select product being sold and quantity multiple products can be sold at a time, 

What I am struggling with is, to update the Sold field when product is sold

I have a function with following code

void Sold.UpdateSold(int id)
{
transactions = Sale[Products.ID == id];
Soldcount = 0;
for each  transactionToSum in transactions
{
Soldcount = Soldcount + transactionToSum.Qty;
}
UpdateSold = Products[ID == id];
UpdateSold.Sold=Soldcount;
}

Then a Form workflow, when New Sale form is subbmitted

for each  rec in input.Product_Sale
{
thisapp.Sold.UpdateSold(input.Product_Sale.ID);
}

when I run the form and submit I get following error

Error details:
 Error in executing On Create / Edit - On Success script
 Error in executing thisapp.Sold.UpdateSold function. Line:(3)
 Unable to update the value to UpdateSold.Sold. Line:(10)
 'UpdateSold' has no matching records. Unable to update the value UpdateSold.Sold. Line:(10)

Please can someone help me:(

Thank you

1 user has this question.
3 Replies
Reply
  • Zoho MVP
  • 17 days ago

  1. void Sold.UpdateSold(int psRecordID)
  2. {
  3.       //fetch ps record
  4.       psRecord = Products[ID = input.psRecordID];
  5.       //check if it finds a record
  6.       if psRecord.count() > 0
  7.       {
  8.             //fetch se record
  9.             seRecord = Sale[Products = psRow.Products];
  10.             //
  11.             psRecord.Sold = ifnull(seRecord.sum(Qty),0);
  12.       }
  13. }
And if calling it from the "On Success" of the main form, something like:
  1. //
  2. for each psRow in input.Product_Sale
  3. {
  4.       //
  5.       thisapp.Sold.UpdateSold(psRow.Product);
  6. }

  • 12 days ago

Hi Masid-e-Ghosia,

I hope you're doing well. We've created a video to help with your issue. Please watch the video to understand the solution and apply the same approach to resolve your problem. If you have any questions or encounter any issues, feel free to reach out to us.


I have also corrected your code below. Please copy and paste the updated function into your application, and it should work perfectly:

void Sold.UpdateSold(int id)
{
    prd_obj = Products[ID == input.id];
    if (prd_obj.count() > 0)
    {
        transactions = Sale[Products.ID == prd_obj.ID];
        prd_obj.Sold = transactions.sum(Qty);
    }
}
Then, for the form workflow, when the "New Sale" form is submitted:

for each rec in input.Product_Sale
{
    thisapp.Sold.UpdateSold(input.Product_Sale.ID);
}


Regards,
Roy Vargis
support@zentegra.com

  • 10 days ago

Hi Masid-e-Ghosia,

I hope you're doing well. We've created a video to help with your issue. Please watch the video to understand the solution and apply the same approach to resolve your problem.


I have also corrected your code below. Please copy and paste the updated function into your application, and it should work perfectly:

void Sold.UpdateSold(int id)
{
    prd_obj = Products[ID == input.id];
    if (prd_obj.count() > 0)
    {
        transactions = Sale[Products.ID == prd_obj.ID];
        prd_obj.Sold = transactions.sum(Qty);
    }
}
Then, for the form workflow, when the "New Sale" form is submitted:

for each rec in input.Product_Sale
{
    thisapp.Sold.UpdateSold(input.Product_Sale.ID);
}


Regards,
Roy Vargis

Reply to Admin@Masjid-e-GhosiaA
/* */
  • 12
  • Insert
  • Plain text
Add Comment
(Up to 20 MB )