Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP forum
Answered

Check for duplicated SIN with sanscript and EOne Extender

Posted on by 50

Hello all,

My company is using  Canadian Payroll, in addition to eOne's eXtender product.

I am trying to create a sanscript script which will run under an eXtender action, that will open a prompt whenever our Payroll enters in a SIN that is already in CPY10100 (aka an employee who already exists).

I copied an existing template from eOne found here: https://www.eonesolutions.com/extender/downloads/#Templates or below

local text lt_sql;
local long ll_sql_connection, ll_status;
local integer li_sop_type;
local string ls_sop_number;

if empty(<Customer PO Number>) or empty(<Customer Number>) then
    abort script;
end if;

SQL_Connect(ll_sql_connection);

lt_sql = "USE " + 'Intercompany ID' of globals;
SQL_Execute(ll_sql_connection, lt_sql);

{check if customer and po combination exists in work table}
lt_sql = "select SOPTYPE, SOPNUMBE from SOP10100 where ";
lt_sql = lt_sql + "CUSTNMBR = " + SQL_FormatStrings(<Customer Number>) + " and ";
lt_sql = lt_sql + "CSTPONBR = " + SQL_FormatStrings(<Customer PO Number>) + " and ";
lt_sql = lt_sql + "not (SOPNUMBE = " + SQL_FormatStrings(<SOP Number>) + " and SOPTYPE = " + str(<SOP Type>) + ")";

ll_status = SQL_Execute(ll_sql_connection, lt_sql);
if ll_status = 0 then
    ll_status = SQL_FetchNext(ll_sql_connection);
    if ll_status = 0 then
        SQL_GetData(ll_sql_connection, 1, li_sop_type);
        SQL_GetData(ll_sql_connection, 2, ls_sop_number);
    end if;
end if;

if empty(ls_sop_number) then
    {check if customer and po combination exists in history table}
    lt_sql = "select SOPTYPE, SOPNUMBE from SOP30200 where ";
    lt_sql = lt_sql + "CUSTNMBR = " + SQL_FormatStrings(<Customer Number>) + " and ";
    lt_sql = lt_sql + "CSTPONBR = " + SQL_FormatStrings(<Customer PO Number>);
    ll_status = SQL_Execute(ll_sql_connection, lt_sql);
    if ll_status = 0 then
        ll_status = SQL_FetchNext(ll_sql_connection);
        if ll_status = 0 then
            SQL_GetData(ll_sql_connection, 1, li_sop_type);
            SQL_GetData(ll_sql_connection, 2, ls_sop_number);
        end if;
    end if;
end if;

if not empty(ls_sop_number) then
    case ask("A document has already been entered for this customer with this purchase order number.", "Open Inquiry", "Continue", "Delete")
        in [ASKBUTTON1]
            open form SOP_Document_Inquiry;
            if isopen(form SOP_Document_Inquiry) then
                'Sort By' of window SOP_Document_Inquiry of form SOP_Document_Inquiry = 1;
                run script 'Sort By' of window SOP_Document_Inquiry of form SOP_Document_Inquiry;
                'All Or Range' of window SOP_Document_Inquiry of form SOP_Document_Inquiry = 1;
                run script 'All Or Range' of window SOP_Document_Inquiry of form SOP_Document_Inquiry;
                'Start SOP Number' of window SOP_Document_Inquiry of form SOP_Document_Inquiry = ls_sop_number;
                'End SOP Number' of window SOP_Document_Inquiry of form SOP_Document_Inquiry = ls_sop_number;
                'Include GB' of window SOP_Document_Inquiry of form SOP_Document_Inquiry = 1;
                run script 'Include GB' of window SOP_Document_Inquiry of form SOP_Document_Inquiry;
                run script 'Redisplay Button' of window SOP_Document_Inquiry of form SOP_Document_Inquiry;
            end if;
        in [ASKBUTTON3]
            {run script delayed 'Delete Button' of window SOP_Entry of form SOP_Entry;}
    end case;
end if;

SQL_Terminate(ll_sql_connection);

I modified it to be the following ,and it is 'valid' according to the extender window. However, no popup appears when a duplicate SIN is entered or changed in a test client.

local text lt_sql;
local long ll_sql_connection, ll_status;
local string ls_sin_number;

if empty(<P_Employee_ID>) or empty(<P_Social_Insurance_Number>) then
    abort script;
end if;

SQL_Connect(ll_sql_connection);

lt_sql = "select Distinct PSocialInsuranceNumber from CPY10100 where ";
lt_sql = lt_sql + "PSocialInsuranceNumber = " + SQL_FormatStrings(<P_Social_Insurance_Number>);

ll_status = SQL_Execute(ll_sql_connection, lt_sql);
if ll_status = 0 then
    ll_status = SQL_FetchNext(ll_sql_connection);
    if ll_status = 0 then
        SQL_GetData(ll_sql_connection, 1, ls_sin_number);
    end if;
end if;


if not empty(ls_sin_number) then
    ask("A employee already exists with this SIN.", "Continue","Continue","Continue");
end if;
SQL_Terminate(ll_sql_connection);

Any help or suggestions would be great!

Thanks!

  • Verified answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,833 Moderator on at
    RE: Check for duplicated SIN with sanscript and EOne Extender

    Hi Josh

    I took the liberty of coding an example GP Power Tools - Developer Tools module project which handles your requirement (and more).

    I have emailed it to you. If anyone else is interested, please contact me using the Contact Us page (https://www.winthropdc.com/contact.htm)

    I will eventually publish this example as a blog article on http://www.winthropdc.com/blog 

    Regards

    David

  • Almas Mahfooz Profile Picture
    Almas Mahfooz 10,996 User Group Leader on at
    RE: Check for duplicated SIN with sanscript and EOne Extender

    Dexterity is Sanscript IDE.

    I am confuse, if you don't have the IDE then where you have this code and checking of message pop up or not?

  • Suggested answer
    Beat Bucher  GP Geek  GPUG All Star Profile Picture
    Beat Bucher GP Gee... 28,021 Moderator on at
    RE: Check for duplicated SIN with sanscript and EOne Extender

    As I said, one way to get this working without too much efforts and investments is to use GPPT (winthropdc.wordpress.com/.../) and see if you can achieve the same result with less coding.. GPPT's dev module supports SQL, VB, Dexterity, C# and possibly also sanscript.

    I'll bet David Musgrave will be able to assist with your problem.. 

    BTW, The GP SDK and Dexterity dev environment is free to install along your GP setup, and David also provides a free library called VSIT (Visual Studio Integration Toolkit) that allows .NET developers to natively access GP functions within Visual Studio.

  • jgilker Profile Picture
    jgilker 50 on at
    RE: Check for duplicated SIN with sanscript and EOne Extender

    Hi Beat,

    I will reword my question. I am not sure what is wrong in my code. Any tips or suggestions to make the code work the way I am wanting it to work would be greatly appreciated.

    Sadly, I do not have a Dynamics / Sanscript IDE, so I cannot easily test this code out. If you know of any IDE that can handle Sanscript, could you let me know? That would also be appreciated.

  • Beat Bucher  GP Geek  GPUG All Star Profile Picture
    Beat Bucher GP Gee... 28,021 Moderator on at
    RE: Check for duplicated SIN with sanscript and EOne Extender

    Hi,

    I don't quite get the question of your post ? you found some code on eOne's site for Extender, but don't know how to implement it ? is that the purpose of the question ?

    Please advise to get a more precise answer.

    Thanks

  • DexDev Profile Picture
    DexDev 100 on at
    RE: Check for duplicated SIN with sanscript and EOne Extender

    Hi,

    If you are looking for a code assistance, kindly let me know. 

    Get help with your project here.

    J.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Product updates

Dynamics 365 release plans