Hi,
In the view attached below for attachments, if no file is added then submit action should not happen. This is handled in the OnClientClick event of "AttachAdd" button which in turn calls the isFileLoaded function.
The document.forms[0].<%= controller->gc_document_path %>.value is always throwing error. I also tried document.getElementById('<%= controller->gc_document_path %>')
No form tag is used here. Can any one help me regarding this? The view is attached below for reference.
Thanks & Regards
G.Raja
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<%@extension name="xhtmlb" prefix="xhtmlb" %>
<%@extension name="CRM_BSP_IC" prefix="crmic" %>
<script>
function isFileLoaded()
{
if (document.forms[0].<%= controller->gc_document_path %>.value == '' ||
document.forms[0].<%= controller->gc_document_path %>.value == null)
return false;
else
return true;
}
</script>
<%
switch to correct encoding type for binary file upload
try.
DATA: frm TYPE REF TO CL_HTMLB_FORM.
frm ?= melem->get_class_named_parent( 'CL_HTMLB_FORM' ).
frm->encodingtype = 'multipart/form-data'.
frm->method = 'POST'.
catch cx_root.
endtry.
%>
<%
data: lt_attachments type O2PARAVALU_TABLE.
data: lv_attachment type crmt_ic_mail_attachment.
data: lv_del_mode type string.
data: lv_filename type string.
IF Attachments IS BOUND.
if Attachments->currentattachments is initial.
lv_del_mode = 'true'.
else.
lv_del_mode = 'false'.
endif.
ENDIF.
%>
<script type="text/javascript" language="javascript">
crmICWCswitchEnctypeToMultipart();
</script>
<crmic:tray2 id="ZOrderAttachments"
title="<%= otr(ZEID/Attachmenttitle) %>"
height = "100%,203"
width="100%">
<crmic:trayBody2>
<crmic:gridLayout cellSpacing = "1"
columnSize = "1"
rowSize = "5"
height = "100%"
width = "100%">
<crmic:gridLayoutCell colSpan="1"
columnIndex="1"
horizontalAlignment="LEFT"
rowIndex="1">
<htmlb:link id="Action"
onClick="Action"
text="<%= OTR(ZEID/ACTION) %>"/>
</crmic:gridLayoutCell>
<crmic:gridLayoutCell columnIndex="1" rowIndex="2" height="100%">
<crmic:tableView id = "Attachments"
headerText = "<%= otr(zEID/attachments) %>"
navigationMode = "BYPAGE"
table = "<%= Attachments->currentattachments %>"
selectionMode = "multiselect"
design = "alternating"
onRowSelection = "MyEventRowSelection"
fillUpEmptyRows = "true"
visibleRowCount = "3"
width = "100%" >
<crmic:tableViewCols>
<crmic:tableViewColumn columnName = "filetype"
title = "<%= otr(CRM_IC_APPL/type) %>"
type = "user" >
<htmlb:image src = "$TVCVALUE$"
/>
</crmic:tableViewColumn>
<crmic:tableViewColumn columnName = "filename"
title = "<%= otr(CRM_IC_APPL/document_name) %>"
type = "user"
linkColumnKey = "true" >
<htmlb:link id = "$TVCID$"
reference = "$URL$"
target = "_blank"
text = "$TVCVALUE$"
>
</htmlb:link>
</crmic:tableViewColumn>
</crmic:tableViewCols>
</crmic:tableView></crmic:gridLayoutCell>
<crmic:gridLayoutCell columnIndex="1" rowIndex="3"
><crmic:button id = "AttachAdd"
text = "<%= otr(CRM_IC_APPL/add) %>"
tooltip = "<%= otr(CRM_IC_APPL/add) %>"
onClick = "AddAttachment"
onClientClick = "if(!isFileLoaded()) htmlbevent.cancelSubmit = true;"
/> <crmic:button id = "AddtachDel"
disabled = "<%= lv_del_mode %>"
text = "<%= otr(CRM_IC_APPL/deletemail) %>"
tooltip = "<%= otr(CRM_IC_APPL/deletemail) %>"
onClick = "DeleteAttachments"
/> <htmlb:fileUpload id = "<%= controller->gc_document_path %>"
size = "30"
/></crmic:gridLayoutCell>
</crmic:gridLayout>
</crmic:trayBody2>
</crmic:tray2>