Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Can't find where this variable comes from

(0) ShareShare
ReportReport
Posted on by 148

Hi,

I'm creating a job in order to fix some date values from a field called DueDate in the table CustTrans. Those values are now saved correctly when they go through this process: 

if (! CustPaymSched::exist(salesParmTable.TableId,salesParmTable.RecId))
    {
        custVendPaymSched = CustVendPaymSched::construct(SysModule::Cust,salesParmTable);

        if (specQty.selection() == SalesUpdate::All && CustPaymSched::exist(salesParmTable.salesTable().TableId, salesParmTable.salesTable().RecId))
        {
            custVendPaymSched.copyCustVendPaymSched(CustPaymSched::find(salesParmTable.salesTable().TableId, salesParmTable.salesTable().RecId));
        }
        else
        {
            custVendPaymSched.copyPaymSched(PaymSched::find(salesParmTable.salesTable().PaymentSched));
            salesParmTable.createPaymentSched();
        }
    }

Because I need to correct the previous ones, I'm testing a single record and I want to pass them through the same process like this:

static void CorregirFechaVencimiento(Args _args)
{
    CustTrans custTrans;
    CustVendPaymSched custVendPaymSched;
    SalesParmTable salesParmTable;

    ttsbegin;

    select forupdate custTrans where custTrans.RecId == 5637617829;

    if (custTrans)
    {
        if (! CustPaymSched::exist(salesParmTable.TableId,salesParmTable.RecId))
        {
        custVendPaymSched = CustVendPaymSched::construct(SysModule::Cust,salesParmTable);

        if (specQty.selection() == SalesUpdate::All && CustPaymSched::exist(salesParmTable.salesTable().TableId, salesParmTable.salesTable().RecId))
        {
            custVendPaymSched.copyCustVendPaymSched(CustPaymSched::find(salesParmTable.salesTable().TableId, salesParmTable.salesTable().RecId));
        }
        else
        {
            custVendPaymSched.copyPaymSched(PaymSched::find(salesParmTable.salesTable().PaymentSched));
            salesParmTable.createPaymentSched();
        }
        }

        custTrans.update();
    }

    ttscommit;
}


But I'm getting the error: The specQty variable has not been declared.

I'm trying to naviagte to the definition but I get the message: Cannot navigate to the definition. I also checked the original code where that process was located (it was inside a form called SalesEditLines) and I don't see anywhere the variable declared, neither in the classDeclaration and I don't know why it doesn't give the error there.

I don't know if this has something to do with this, but I found specQty as a method in a class SalesFormLetter but obviously that is the method and not a variable and it doesn't have the method used in the process named selection()

Thanks in advance.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,558 Moderator on at
    RE: Can't find where this variable comes from

    Hi Daniel, You can modify the code in your job, since specQty is a form control and user selects value in it, your job will not have access to it. You need to either hard code the value in code for specQty or create dialog for user selection.

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: Can't find where this variable comes from

    Hi Daniel,

    I think SpecQty is the control on the form. In the form they will set the Auto declaration property to Yes on that control and use that in the code by mentioning the control name.

    Thanks,

    Girish S.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,349 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,029 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans