Script Include with indexOf method

Annette Kitzmil
Tera Guru

Hello,

 

Below is a script include that when it gets to the section that is this color, it doesn't pick up the var backDating part that is part of the correction part of the function.  I can get a gs.addInfoMessage just inside of that part of the function, but I can't get a gs.addInfoMessage just past that part of the function, therefore, the conditions are skipped over.  What do I need to change here please so that it is picking up the var backDating.

 


    canViewConfirmButton: function() {

        var isMemberAccountService = gs.hasRole('x_mtbr_ebs_rdep.account_services');
        var isOpenedBy = gs.getUserID() == current.getValue('opened_by');

        var isOpenAccount = current.open_account == true;

        var existingCustomer = current.type_of_customer == 'existing customer';
        var prospectCustomer = current.type_of_customer == 'prospect customer';

        var statusPtApproved = current.status == 'pt_approved';
        var statusConfirmed = current.status == 'confirmed';
        var statusCorSupportApproved = current.status == 'cor_support_approved';

        if (this.requestType == 'correction') {
            //Correction Logic

            // var ct = current.type_of_correction_requested;
            // ct = ct.split(',');

            // var backDating = ct.indexOf(gs.getProperty('x_mtbr_ebs_rdep.redp.backdating_request')) >= 0;

            if (statusPtApproved || statusCorSupportApproved || statusConfirmed) {

                //This is for the Opened by user to confirm when Open Account is true and either PT Approved or Cor Support Approved
                if (isOpenAccount && isOpenedBy) {
                    return true;
                }

                //This is for Account Services when backDating and is either PT Approved or Cor Support Approved
                if (isMemberAccountService && backDating) {
                    return true;

                }

                //This is for an Opened by User Confirmed case with Open Account and includes backDating that Account Services is now Confirming so it routes to WNS
                if (isMemberAccountService && isOpenAccount && backDating) {
                    return true;
                }
            }

        } else {
            //Exception Logic

            if (statusPtApproved && existingCustomer && isOpenAccount && isOpenedBy) {
                return true;
            }

            if (statusPtApproved && prospectCustomer && isOpenedBy) {
                return true;
            }
        }

        return false;


    },

 

Thank you ahead of time for any help on this script.

 

1 ACCEPTED SOLUTION

OK, so ct is some comma-separated value, and the system property contains a value to search for. 

I'm going to assume that's like ct = sys_id1,sys_id2,sysid3.., and the Value of the system property is one of those sys_ids.  Let me know if this is not remotely close.

You can use indexOf in an array or string, but if all you are trying to determine is if the sys_id that is the Value of the system property appears anywhere in the field value, you don't need an array, so leave that out.  With the logs of ct and the system property still there as a sanity check, if you add back in the backDating line then log that variable right after, what do you get?

One thing you should do that shouldn't matter but can't hurt is force the values to a string, since they contain sys_ids.  Stranger things have worked.  And maybe get ridiculous with breaking this apart and logging to see if that sheds any light:

var ct = current.type_of_correction_requested.toString();
gs.info ('AK ct= ' + ct);
var sysprop = gs.getProperty('x_mtbr_ebs_rdep.redp.backdating_request').toString();
gs.info ('AK sysprop= ' + sysprop);
var backDating = ct.indexOf(sysprop) >= 0;
gs.info ('AK backDating= ' + backDating);

 

View solution in original post

7 REPLIES 7

Brad Bowman
Kilo Patron
Kilo Patron

I would start by logging ct before the split and 

gs.getProperty('x_mtbr_ebs_rdep.redp.backdating_request')

to make sure you have expected values in both of those before trying to use them.

What are you trying to get for backDating?  You probably either want to not split ct so that you are executing this search on the full string instead of an array, and maybe get rid of the >=0.

Hi Brad,

So, the field allows the user to select more than one option for the type of correction requested, which is why the array is being utilized.  So, I need to ensure that no matter what order the user selects the options in, that if backDating is included, it sees it.  

 

When I tried logging ct before the split and 

gs.getProperty('x_mtbr_ebs_rdep.redp.backdating_request')

, I get nothing at that point either, so I am not sure what it isn't liking right now.

Sorry, I forgot I had the lines commented out and I am indeed getting back a value for the logs mentioned above as expected.

OK, so ct is some comma-separated value, and the system property contains a value to search for. 

I'm going to assume that's like ct = sys_id1,sys_id2,sysid3.., and the Value of the system property is one of those sys_ids.  Let me know if this is not remotely close.

You can use indexOf in an array or string, but if all you are trying to determine is if the sys_id that is the Value of the system property appears anywhere in the field value, you don't need an array, so leave that out.  With the logs of ct and the system property still there as a sanity check, if you add back in the backDating line then log that variable right after, what do you get?

One thing you should do that shouldn't matter but can't hurt is force the values to a string, since they contain sys_ids.  Stranger things have worked.  And maybe get ridiculous with breaking this apart and logging to see if that sheds any light:

var ct = current.type_of_correction_requested.toString();
gs.info ('AK ct= ' + ct);
var sysprop = gs.getProperty('x_mtbr_ebs_rdep.redp.backdating_request').toString();
gs.info ('AK sysprop= ' + sysprop);
var backDating = ct.indexOf(sysprop) >= 0;
gs.info ('AK backDating= ' + backDating);