How keep a changed register

LeroyLeroy Member Posts: 199
Hi everybody; I've the following code
 IF (xRec."Shipment Date"<>0D) THEN BEGIN
IF "Cód. Product manager" = 'PM-EDY' THEN BEGIN
Mail.NewMessage('adm@company.com','','Has been modify the date form the item '
 + "No."+' from order '+"Document No."+'date'+ (FORMAT("Shipment Date")),
'','',FALSE);
END;
END;

Mail is codeunit Mail

This is on "Shipment date" field form Sales line table. It sends an e-mail to the product manager from the item when the shipment date modifies, and puts the new date; it runs perfectly. But, how can I do to put also the old date, I mean, the date that has been changed?.
Thanks for help.

Comments

  • MBergerMBerger Member Posts: 413
    Leroy wrote:
    Hi everybody; I've the following code
     IF (xRec."Shipment Date"<>0D) THEN BEGIN
    IF "Cód. Product manager" = 'PM-EDY' THEN BEGIN
    Mail.NewMessage('adm@company.com','','Has been modify the date form the item '
     + "No."+' from order '+"Document No."+'date'+ (FORMAT("Shipment Date")),
    '','',FALSE);
    END;
    END;
    

    Mail is codeunit Mail

    This is on "Shipment date" field form Sales line table. It sends an e-mail to the product manager from the item when the shipment date modifies, and puts the new date; it runs perfectly. But, how can I do to put also the old date, I mean, the date that has been changed?.
    Thanks for help.
    It's right there, in front of you.... xrec."shipment date"
  • LeroyLeroy Member Posts: 199
    Thanks for reply. But I've put (xRec."Shipment Date"<>0D) because I don't want the the e-mail sends on first time. How should be the code for it?.
    Thanks.
  • MBergerMBerger Member Posts: 413
    Leroy wrote:
    Thanks for reply. But I've put (xRec."Shipment Date"<>0D) because I don't want the the e-mail sends on first time. How should be the code for it?.
    Thanks.
    Please tell me if i am wrong, but you want to have both the original date and the date is has been changed to in the mail ?
    then you could do something like :
    Mail.NewMessage('adm@company.com','','Has been modify the date form the item ' + "No."+' from order ' + "Document No." + ' original date : '+ (FORMAT(xrec,"Shipment Date") + ' new date : ' + FORMAT(xrec,"Shipment Date"),
    '','',FALSE);
    
  • LeroyLeroy Member Posts: 199
    Yes!!, it works perfectly =D> .
    Thanks you very much for your help and time.
  • kinekine Member Posts: 12,562
    Just one tip:
    IF "Cód. Product manager" = 'PM-EDY' THEN BEGIN
    

    Using "magic constants" is not good design... :whistle:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • LeroyLeroy Member Posts: 199
    Thanks. Another question if you're so kind :roll: . The problem with this code is that a mail is send with only put the cursor on the field, not only when it changes. Is there any way that it sends a mail when the information is changed not putting the mouse on the field?.
    Also I've noticed that it sends and e-mail the first time that I put the date. I supossed that putting (xRec."Shipment Date"<>0D) the mail sends when the field modifies, but it doesn't work. What could be the problem also?

    I put the code:
     IF (xRec."Shipment Date"<>0D) THEN BEGIN
    IF "Cód. Product manager" = 'PM-EDIE' THEN BEGIN
    CodeMail.NewMessage('mail@mail.com','','The date is modified  '+FORMAT(xRec."Shipment Date")
    + ' date '+(FORMAT("Shipment Date"))+'    Item: '
     + "No."+'    Order: '+"Document No.",
    '','',FALSE);
    END;
    END;
    

    Thanks again for help.
  • kinekine Member Posts: 12,562
    What about something like:
    if (xRec."Shipment Date"<>xRec."Shipment Date") and ("Shipment Date"<>0D) then
    

    - it means "if date was changed and is filled by some value..."
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • LeroyLeroy Member Posts: 199
    Yes, it works!!!. =D>
    Thanks for help and time.
  • kinekine Member Posts: 12,562
    I have typo in my example, correct one is:
    if (xRec."Shipment Date"<>"Shipment Date") and ("Shipment Date"<>0D) then
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • LeroyLeroy Member Posts: 199
    Yes, thanks, I've had "corrected", but the idea was the important. My code remains like this:
    IF (xRec."Shipment Date"<>0D) AND ((FORMAT(xRec."Shipment Date"))<>(FORMAT("Shipment Date")))
    

    Thanks again for help.
  • kinekine Member Posts: 12,562
    Just remove the "Format" because it is not needed and it have no meaning there...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.