Announcement

Collapse
No announcement yet.

delete msg['IN1'][i]['IN1.12'].toString()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • delete msg['IN1'][i]['IN1.12'].toString()

    Hello, I am trying to delete any msg['IN1'][i]['IN1.12'].toString() in the Insurances segment. Here is my code:

    var segName = msg['IN1'][i]['IN1.12']['IN1.12.1'].Length();
    for (var i = 0; i <= msg. msg['IN1'].length(); i++)
    {
    delete segName;
    }

    But looks like this code is not working. Can anyone please help? Thanks

  • #2
    Close...try this..

    Code:
    for(i=0;i<msg['IN1'].length();i++)
    {
    	if(msg['IN1'][i]['IN1.12']['IN1.12.1'].toString().length > 0)
    	{
    		delete msg['IN1'][i]['IN1.12'];
    	}
    }
    You were trying to set a variable including [i], when [i] had not been defined yet. So, your segName variable should have been inside the for loop.
    Last edited by mcalKno; 07-24-2015, 09:51 AM.

    Comment


    • #3
      Thank you so much for your help! But even I've tried your code, but still not delete segment ] msg['IN1'][i]['IN1.12'].

      Here is I just did a test result:

      MSH|^~\&|ADT|ADMIT|NEXTGEN||201507241317||ADT^A31| 08798238|P|2.3|||NE|NE|US|||
      EVN|A31|201507241317||||||
      PID|1||482209|000001000500|Test^Mirth7||20110308|M ||A|test mirth7 street^""^Omaha^NE^68116|0819^Douglas|(402)402-6976||AFR^Afrikaans|||||||3|||||0|||N||||||||||
      PD1|||||||||||||
      IN1|1|C018|C018|American Community Private Policies|39201 7 Mile Rd||(800)991-2642|||||20150717||I1248575||Test^Mirth7|18|201103 08||||1||||||||||||||797098089089-089-089-89-9|||||||M^Male||||||482209|
      ZPX|20150708|20150716|||

      You can see '20150717' still there...

      Comment


      • #4
        Originally posted by Wenhong View Post
        Thank you so much for your help! But even I've tried your code, but still not delete segment ] msg['IN1'][i]['IN1.12'].

        Here is I just did a test result:

        MSH|^~\&|ADT|ADMIT|NEXTGEN||201507241317||ADT^A31| 08798238|P|2.3|||NE|NE|US|||
        EVN|A31|201507241317||||||
        PID|1||482209|000001000500|Test^Mirth7||20110308|M ||A|test mirth7 street^""^Omaha^NE^68116|0819^Douglas|(402)402-6976||AFR^Afrikaans|||||||3|||||0|||N||||||||||
        PD1|||||||||||||
        IN1|1|C018|C018|American Community Private Policies|39201 7 Mile Rd||(800)991-2642|||||20150717||I1248575||Test^Mirth7|18|201103 08||||1||||||||||||||797098089089-089-089-89-9|||||||M^Male||||||482209|
        ZPX|20150708|20150716|||

        You can see '20150717' still there...
        Just to confirm, your destination is set to use the encoded template? I used your sample message and it worked fine.

        Comment


        • #5
          I am using ${message.encodedData} in the Template...


          Maybe I will try to stop Mirth and restart it to see if it works..I will let you know..Thanks

          Comment


          • #6
            This runs backwards and does the same result.. from the look of things you arent wanting to delete segments just clear a value in IN1.12.1.. this might work for you.

            Code:
            var i = msg['IN1'].length();
            
            while (i--)
            {
            	msg['IN1'][i]['IN1.12']['IN1.12.1'] = '';
            }
            Last edited by glenn71; 07-27-2015, 03:25 AM.

            Comment


            • #7
              Thank you so much! After I reboot Mirth, It is working now.

              Comment


              • #8
                Thank you glenn71! This code is working too.!!

                Comment

                Working...
                X