List of Merge fields in WP4

  • Hi Julian,

    Is there a way in the WP4 top get the list of the merge fields in a single method like in WP5:

    CodeListTags(wpobjMergeField, '*ALL*', True)

    Or do I have to loop through all the Fields, that I "Find"

    Thanks

    The little green man

  • I've create an event that will handle the problem I had in th OP
    I can create a List of all the inspname EditFields for the document.

    My problem is with the MergeText, I can't seem to figure out what step I'm forgetting ....

    Code
    for i:= 0 to FEditor.HeaderFooter.Count - 1 do  begin    if not (FEditor.HeaderFooter.Items[i].Empty) then    begin     FEditor.HeaderFooter.Items[i].WorkOnText := True;     FEditor.MergeText;    end;  end;  FEditor.WorkOnText := wpBody;  FEditor.MergeText;

    I know I have seen a example on your site, but can't seem to find it, I just can't seem to make the Merge part work, this is the Merge Event


    TIA, for the help and suggestions...

    the Little green man

  • the inspname is used to locate in a DataSet the map to the table-field pair that will contain the data to be inserted in the EditField.

    Once it is located it's set to a local var

    Code
    vFieldName := ParseNomChampsToAlias(dstMotsCles.FieldByName('NOMCHAMP').AsString); 
    
    
    ...
    
    
    Contents.StringValue := qryGeneric.FieldByName(vFieldName).AsString;


    qryGeneric, is a TQuery, that has been built dynamically from the list of merge fields found in the current document being asked to merge.

    I'm just trying to figure out what part I'm not doing right, because I can't see the values that were used to replace the MergeFields [inspname], but I see the values when debugging, that is returned by the query, but when looking at the end printed result I only see the static text that is in the document.... So that's why I think I'm just missing a small part for it to work ...


    I have tried a couple of things but I can't make it work so far...

    Any suggestions or questions are welcome.

    The little green man

    • Offizieller Beitrag

    Hi,

    please note, MaileMerge does not "replace" fields, it inserts the data after the "insertpoint". (In WPTools 5 it inserts BETWEEN start and end tag)

    I hope you do not call MergeText for each field, such as MergeText('name'), MergeText('str') etc. That is not a perfect approach and can be the reson no field is merged since the field name ios not found.

    Use MergeText('') and check for property inspname in the event.

    I ask this because you equation
    vFieldName := ParseNomChampsToAlias(dstMotsCles.FieldByName('NOMCHAMP').AsString);

    does NOT have a variable.

    Kind Regards,

    Julian Ziersch

  • Zitat


    please note, MaileMerge does not "replace" fields, it inserts the data after the "insertpoint". (In WPTools 5 it inserts BETWEEN start and end tag)

    I hope you do not call MergeText for each field, such as MergeText('name'), MergeText('str') etc. That is not a perfect approach and can be the reson no field is merged since the field name ios not found.

    Use MergeText('') and check for property inspname in the event.

    As I said in a previous post, this is the code that will call the MergeText event, no data manipulation with inspname at this point.

    Code
    for i:= 0 to FEditor.HeaderFooter.Count - 1 do  begin    if not (FEditor.HeaderFooter.Items[i].Empty) then    begin     FEditor.HeaderFooter.Items[i].WorkOnText := True;     FEditor.MergeText;    end;  end;   FEditor.WorkOnText := wpBody;  FEditor.MergeText;

    As for this part of the code

    Code
    vFieldName := ParseNomChampsToAlias(dstMotsCles.FieldByName('NOMCHAMP').AsString);

    This is just to get the name of the field in the generic query that is associated with the inspname and will have the data that needs to be merged in that position.

    I know I'm not that far because when I debug I see that the right values are returned from the generic query, the part I still haven't figured out is why I can't see the values I have inserted in the document.

    Is there any options I should make sure are set ?

    Am I missing a key Refresh/ReformatAll/ or something else ?

    I could create a sample that doesn't involve a database to show you the entire code, so you can see where I make my mistake.

    The Little Green_Man