BN for Blocked Customer does not send email

gunshygunshy Member Posts: 43
Hi!

Can anyone help me.
I successfully installed BN, and tested some of its templates, and worked perfectly fine.
But I tried to create the sample from the Application Designer's Guide on which a notification will be sent if a customer has been blocked,
but BN does not sent any email.
I checked the code for the trigger in OnModify event and it's working fine.

Thanks

Comments

  • kinekine Member Posts: 12,562
    Did you subscribe for the notification?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • gunshygunshy Member Posts: 43
    I had my email address in the internal and external receiptients.
    I think the problem is the XMLPort, I found this error in the Event Log:

    Unknown error!
    System.Xml.XmlException: There are multiple root elements. Line 8, position 2.
    at System.Xml.XmlTextReader.ParseRoot()
    at System.Xml.XmlTextReader.Read()
    at System.Xml.XmlValidatingReader.ReadNoCollectTextToken()
    at System.Xml.XmlValidatingReader.Read()
    at System.Xml.XmlLoader.LoadCurrentNode()
    at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
    at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
    at System.Xml.XmlDocument.Load(XmlReader reader)
    at System.Xml.XmlDocument.LoadXml(String xml)
    at Microsoft.BusinessSolutions.Integration.MessageBusAgent.Agent.PublishEvents()
  • kinekine Member Posts: 12,562
    Than your XMLPort is made for exporting just one record and not multiple. You need to add one attribute to first level and nest other attributes to have just one root element.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • gunshygunshy Member Posts: 43
    In the first level I have:

    TagName: Customer
    TagType: Element
    SourceType: Table
    DataSource: Customer(Customer)

    Under Customer element (indented) are:
    TagName: MBS_Navision_URL
    TagType: Attribute
    SourceType: Text
    DataSource: <MBS_Navision_URL>

    TagName: No
    TagType: Element
    SourceType: Table
    DataSource: Customer::No.

    TagName: Name
    TagType: Element
    SourceType: Table
    DataSource: Customer::Name

    TagName: Blocked
    TagType: Element
    SourceType: Table
    DataSource: Customer::Blocked

    In the C/AL Editor I have this line of code(below) on OnBeforePassvariable function:
    MBS_Navision_URL := BNManagement.CreatePurchaseOrderURL(Customer."No.");
  • kinekine Member Posts: 12,562
    Yes, but you need something like:
    <Customers>
      <Customer>
         <MBS_Navision_URL >
         <No_>
      <Customer>
         <MBS_Navision_URL >
         <No_>
      <Customer>
         <MBS_Navision_URL >
         <No_>
      <Customer>
         <MBS_Navision_URL >
         <No_>
    
    Else you can export just one customer (and you will need to add some filter on No. before calling the XMLPort).

    Because now you have this output (simplified):
    <Customer>
       <MBS_Navision_URL >
       <No_>
    <Customer>
       <MBS_Navision_URL >
       <No_>
    <Customer>
       <MBS_Navision_URL >
       <No_>
    <Customer>
       <MBS_Navision_URL >
       <No_>
    

    and it means multiple root elements...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • gunshygunshy Member Posts: 43
    Hi Kine,

    An instruction or sample to do this would be highly appreciated.

    [-o< [-o<

    Thanks
  • gunshygunshy Member Posts: 43
    My output XML now looks like this:
    <Customer>
    	<Customers>
    		<No>2ND WAVE</No>
    		<Name>Store Zone, Inc. (2nd Wave Corp.) </Name>
    	</Customers>
    	<Customers>
    		<No>5-STRS</No>
    		<Name>5 Sisters Emporium</Name>
    	</Customers>
    	<Customers>
    		<No>ABRAHAM</No>
    		<Name>Abraham Boutique</Name>
    	</Customers>
    	<Customers>
    		<No>ALTRS</No>
    		<Name>Alturas Supermarket</Name>
    	</Customers>
    	<Customers>
    		<No>ANDRE</No>
    		<Name>Andre Gift Shop Boutique</Name>
    	</Customers>
    	<Customers>
    		<No>ANDRE2</No>
    		<Name>Andre Gift Shop Boutique 2</Name>
    	</Customers>
    

    But I got no email from BN when I tried to blocked a customer. #-o #-o ](*,)
    Do I need to add this notification I made to Business Notification Worksheet which requires a report?

    Thanks
  • kinekine Member Posts: 12,562
    If you want to "fire" the BN notiication in some automatic way, you need to add Event to the XML port and call this event e.g. in the OnValidate or somewhere it will be fired. The example i based on the Notification worksheet and you will need to create the report which will create the needed lines in the sheet...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • gunshygunshy Member Posts: 43
    By following the C/AL code in Business Notification Worksheet form, I learned that I need to add codes in Business Notification Mgt. codeunit which will populate the XMLPort and execute the event. And by clicking Send to Business Notification function in Manufacturing>Execution>Business Notification Worksheet which runs a report that will add records to Notification Line table, the BN will send emails. My question is how the event in XMLPort will add records in Notification Line table where in the Customer table, OnModify event I have this lines of code:
    IF Blocked = Blocked::All THEN BEGIN
      IF Blocked<>xRec.Blocked THEN BEGIN
         CustXMLDoc.HasBeenBlocked();
      END;
    END;
    

    where I cannot add codes in HasBeenBlocked event.

    Thanks
Sign In or Register to comment.