This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - java script method is not returning proper result.

meenu - Tuesday, November 6, 2012 5:40 AM:

Hi,

      I' m trying to get all the documents that are having the document number as "DOC-*" by using a javascript method.

The code that I' m using is:

var innovator = new Innovator();

var doc = innovator.newItem();

doc.loadAML("<Item type='Document' action='get' select='item_number,description'>" +

"<Item_number condition='like'>DOC-*</item_number>" +   "</Item>");

var result = doc.apply();

if (result.isError())    {

top.aras.AlertError("Item not found: " + result.getErrorDetail());

return;  }

var count = result.getItemCount();

for (i=0; i<count; ++i)  {

var item = result.getItemByIndex(i);   }

 On my form I have assigned this method to a field on 'OnClick' event. But when I click on the field It is not getting the documents list, even not throwing any error complaining about something. It Just stays calm after clicking on it.

Is there any mistakes in the above code? Or any other I have missed?

Please help me.

Thank You/ Meenu



PeterSchroer - Tuesday, November 6, 2012 8:54 AM:

Meenu -  please check the <item_number>   tag.   You have "<Item_number ...   with a capital "I" for Item.  

you should see an error message from the Javascript engine,   but I suspect you are running with error event notifications suppressed.

 

--peter



vasant - Thursday, November 8, 2012 4:37 AM:

Hi Meenu,

Try to use following lines of Code:

var innovator = top.aras.newIOMInnovator();
var result=innovator.applyAML("<AML><Item type='Document' action='get' select='item_number,description'>" +
            "<item_number condition='like'>DOC-*</item_number>" +  
            "</Item></AML>");

if (result.isError())
{
    top.aras.AlertError("Item not found: " + result.getErrorDetail());
    return; 
}
var count = result.getItemCount();
for (i=0; i<count; ++i)
{
    var item = result.getItemByIndex(i);
}

Hope it will solve your issue..

Thanks & Regards,

Vasant Padhiyar



meenu - Wednesday, November 7, 2012 6:22 AM:

Thank You Peter,

     Still No change in the result. I' m not able to figure out what the issue with this. No issues with the code, right?But no luck!    

 So, I'm trying in other way by assigning  the URL of the Item to my button. In this case when I click on the button , first the login screen is appearing after that it navigating to the specified Item. 

Is there any way to by pass the login screen ?     

Meenu. 



Shankar - Friday, February 19, 2016 12:08 AM:

Hello guys,

i want to use date condition with Modified_on and want to use 'between'  with from date and to date but AML does not accepting it, plz guide asap..

code as..

var fromDate = new Date();

fromDate.setDate(fromDate .getDate()-1);

var toDate = new Date();

toDate.setDate(getDate());

var myItem = this.newItem("Method","get");

myItem.setAttribute("select","name");

myItem.setProperty("modified_on",fromDate);

myItem.setProperty("modified_on",toDate);

myItem.setPropertyAttribute("modified_on","condition","between");

myItem = myItem.apply();



Shankar - Friday, February 19, 2016 12:08 AM:

Hello guys,

i want to use date condition with Modifioed_on and want to use 'between'  with from date and to date but AML does not accepting it plz guide asap..



PeterSchroer - Wednesday, November 7, 2012 8:11 AM:

First thing I always do Meenu is to test my AML for correctness.     NASH is the most convenient tool for this purpose.    open your browser to  localhost/.../NASH.aspx       of course you should substitute the your correct Host name and Virtual Directory name in this url.

When NASH opens, use the fields at top to login to the server, then paste your AML query into the box and Submit.   Make sure you are using SOAP action ApplyItem   ( or if you want to use ApplyAML,  make sure your XML has the <AML>.... </AML> wrapper. )

My guess is that you have an AML syntax problem,  usually this is with mis-matched tags,  or you are using a capital "I" where lowercase is required.  Remember that XML is case-sensitive.

--peter.



tstickel - Friday, February 19, 2016 10:34 AM:

Try this.  You have to format the dates properly to use them in AML.  Also notice how to use the "between" condition for modified_on.

 

var fromDate = new Date();

fromDate.setDate(fromDate .getDate()-1);

alert(dateFormat(fromDate));

var toDate = new Date();

var myItem = this.newItem("Method","get");

myItem.setAttribute("select","name");

myItem.setProperty("modified_on",dateFormat(fromDate) + " and " + dateFormat(toDate));

myItem.setPropertyAttribute("modified_on","condition","between");

myItem = myItem.apply();

alert(myItem.getItemCount());

 

function dateFormat(d) {

var dateString = d.getFullYear()+"-";

dateString += pad(d.getMonth()+1)+"-";

dateString += pad(d.getDate())+"T";

dateString += pad(d.getHours())+":";

dateString += pad(d.getMinutes())+":";

dateString += pad(d.getSeconds());

return dateString;

}

 

function pad(x) {

return (x<10) ? "0"+x : ""+x;

}



meenu - Thursday, November 8, 2012 12:50 AM:

Peter ,  as you said  I tested (after changing 'I' to 'i') my AML using NASH tool.  The syntax is working fine here, It returned the proper results.

The syntax returned:      <Item type="Document" typeId="B88C14B99EF449828C5D926E39EE8B89" id="32328207CEBC4B7F842CA95986539648"><css is_null="1"> .state {background-color:#9ACD32}</css><current_state_bg_color>#9ACD32</current_state_bg_color><description is_null="1" /><id keyed_name="DOC-00000022" type="Document">32328207CEBC4B7F842CA95986539648</id><state>Released</state><item_number>DOC-00000022</item_number><itemtype>B88C14B99EF449828C5D926E39EE8B89</itemtype></Item>

This is the exact result what I want , But as a method it is not doing this.

Meenu

 



Dave_Rollinson - Thursday, November 8, 2012 4:05 AM:

It sounds like your Method isn't being triggered; have you tried putting an "alert('Hi');" message at the beggining to see if the event is being triggered?



meenu - Thursday, November 8, 2012 4:20 AM:

  Dave, It does that, prompted the alert message.  Looks very strange, it just prompted the alert message.