Below Code not working

Stivan_dsouza21Stivan_dsouza21 Member Posts: 218
hi,

Aged Accounts Receivable Report,
When i Put multiple Responsibility Center the the Below Code does not work.

CustResCenterFilter := Customer.GETFILTER(Customer."Responsibility Center");
Memberof.RESET;
Memberof.SETRANGE(Memberof."User ID",USERID);
Memberof.SETRANGE(Memberof."Role ID",'MARKETING');
IF Memberof.FINDFIRST THEN
BEGIN
CSOmapping.RESET;
CSOmapping.SETRANGE(CSOmapping."User Id",USERID);
CSOmapping.SETRANGE(CSOmapping.Type,CSOmapping.Type::"Responsibility Center");
CSOmapping.SETRANGE(CSOmapping.Value,CustResCenterFilter);
IF NOT CSOmapping.FIND('-') THEN
ERROR('You are not allowed to run the report other than your Responsibility Center')
END;


Please suggest.
Thanks & Regards,
Stivan D'souza

Comments

  • hawkeyehawkeye Member Posts: 51
    If you do not have the marketing role, then no error will occour. Is that intended?

    BR

    Hawkeye

    Edit:
    If Not then you should ad

    End else
    Error('You do not have the marketing role... (or something)');
  • SogSog Member Posts: 1,023
    CSOmapping.SETRANGE(CSOmapping.Value,CustResCenterFilter);

    should be
    csomapping.setfilter
    Because you get a filter, but you set a range at the moment.
    BTW this only works for SQL users, windows users will always be able to run this report (or never if you add the code of hawkeye)
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • hawkeyehawkeye Member Posts: 51
    Yep sog - you are right.

    I assumed that they did not use windowslogon because of the code - but if I was wrong - that might be the problem.

    BR

    Hawkeye
  • james_csjames_cs Member Posts: 39
    I think you need to use SETFILTER instead of SETRANGE.
    CustResCenterFilter := Customer.GETFILTER(Customer."Responsibility Center");
    Memberof.RESET;
    Memberof.SETRANGE(Memberof."User ID",USERID);
    Memberof.SETRANGE(Memberof."Role ID",'MARKETING');
    IF Memberof.FINDFIRST THEN BEGIN
      CSOmapping.RESET;
      CSOmapping.SETRANGE("User Id",USERID);
      CSOmapping.SETRANGE(Type,CSOmapping.Type::"Responsibility Center");
      CSOmapping.SETFILTER(Value,CustResCenterFilter);
      IF NOT CSOmapping.FIND('-') THEN
        ERROR('You are not allowed to run the report other than your Responsibility Center')
    END;
    
  • DenSterDenSter Member Posts: 8,307
    the Below Code does not work
    The below code works exactly the way that it is programmed. If you want us to say anything intelligent about the code that you write, you have to tell us three things:
    1 - show us the code, which you did, so that's good
    2 - tell us what you expected to happen
    3 - describe what actually happened

    By only giving us the code, you are not actually telling us what the problem is. One thing is for sure though, and that is that code ALWAYS does EXACTLY what you tell it to do.
  • Stivan_dsouza21Stivan_dsouza21 Member Posts: 218
    i used setfilter instead of setrange for below line code:
    CSOmapping.SETRANGE(CSOmapping.Value,CustResCenterFilter);
    Thanks & Regards,
    Stivan D'souza
Sign In or Register to comment.