Options

Funformlink: No.=FIELD(No.) How to do it by Cside code ?

emkproemkpro Member Posts: 47
Hi everybody
I am trying to start a list type form by filtered values but I can't just filter them by the field. I need to filter them by an other table then filter by the values I found in my main table I tried a code like this which didn't worked.
ContBusRel.SETRANGE("Business Relation Code",'PROS'); //this works ok
//Cont.GET(ContBusRel."Contact No."); // trying this raises an error
Cont.Setrange("No.",ContBusRel."Contact No."); // this dont work
FORM.RUN(FORM::"ContactList,Cont) //all I have is an empty form
](*,)
ContBusRel is a record var :Contact business relations table
Cont is a record var : contact table

What i want to do is listing lead contacts. I filter contacts type by business contact table and then list them in contact table using thir contact ids [-o<
//EMK\\

Comments

  • Options
    TirtaTirta Member Posts: 53
    edited 2004-12-08
    ContBusRel.SETRANGE("Business Relation Code",'PROS'); //this works ok
    //Cont.GET(ContBusRel."Contact No."); // trying this raises an error
    Cont.Setrange("No.",ContBusRel."Contact No."); // this dont work
    FORM.RUN(FORM::"ContactList,Cont) //all I have is an empty form
    
    ](*,)

    You can try this one:

    ContBusRel.SETRANGE("Business Relation Code",'PROS');
    IF ContBusRel.FIND('-') THEN
    REPEAT
    Cont.SETCURRENTKEY("Company No.");
    Cont.SETRANGE("Company No.",ContBusRel."Contact No.");
    IF Cont.FIND('-') THEN
    REPEAT
    Contact := Cont;
    Contact.INSERT;
    UNTIL Cont.NEXT = 0;
    UNTIL ContBusRel.NEXT = 0;
    FORM.RUN(0,Contact);

    Contact is a record var : contact table --> TEMPORARY TABLE
  • Options
    DenSterDenSter Member Posts: 8,304
    When you execute the code
    ContBusRel.SETRANGE("Business Relation Code",'PROS');
    
    That only sets a filter on the ContBusRel table, it doesn't actually get any records, so the variable is empty at this point, there is nothing to filter your Contact table on.
    You either need to do a FIND or a GET to populate your ConBusRel variable, and then you can use its "Contact No." field to filter your Cont variable. After you have a value in your Cont variable you should have something in your form. This record does not have to be a temporary variable.

    One additional tip though: look into using FILTERGROUP, to prevent users from undoing the filters you set in code.
  • Options
    RobertMoRobertMo Member Posts: 484
    As DenSter said you need to call FIND after SETRANGE to actually read the record from DB. But this will retrieve (only) first ContBusRel and if you use further its field "Contact No." as parm for filter on Cont, you will get only this contact in your list.

    And that's what you don't want.

    That's why you need to circle through all ContBusRel records (filtered by PROS) and use its field "Contact No." to find and somehow mark all the contacts you have found. This can be done either by using MARK function or by "inserting temporary table" techinque. Solution by Tirta is exactly the second one.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    emkproemkpro Member Posts: 47
    I am sorry for late answer but I was unable to concentrate on the matter but the mark function seems to be more suitable for the job.
    (Say.. RobertMo can you give me an example for this function)
    I will have to search it though. I have some doubts about starting a cycle, woudn't it couse heavy load on system. is it soutable for big databases ???
    //EMK\\
  • Options
    TirtaTirta Member Posts: 53
    I prefer to the insert function with temporary table than the mark function.

    Because there would be double job by mark function. First to mark up, second to filter and then show the marked data.
  • Options
    RobertMoRobertMo Member Posts: 484
    sorry for late reply (have been away), but I agree with Tirta. I would prefer using temporary table. Temporary table is actually created in clients memory so inserting (and reading) it doesn't affect network nor server (nor DB).
    So once you have read the record from DB it is better to put it "client's memory" and do all the processing localy...

    Can you do it or you need extra help?
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    emkproemkpro Member Posts: 47
    I guess I will be able to handle myself thanks guys :)
    Still..
    to be honest I would greatly appritiate any additional clues on temp table method if it woudn't be much trouble =P~
    //EMK\\
  • Options
    RobertMoRobertMo Member Posts: 484
    Maybe take a look at CU 418 Login Management. Check the function LookupUserID which reads 2 different tables and fills third (temporary) .Then it shows a lookup form based on this temp table...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Sign In or Register to comment.