Monday, June 6, 2011

To Upload a file in DB(to a field inside the table)

1.Created table called TEST and field names are Get and Update.
2.Generate web services for that table.
3.Create a new UI
4.Add a new upload button and id of that upload is uploader
5.Add a button and change its id as button1
6.Add a click event for the button created .
7.Open the UI and select XML tab and change its content as








Upload:FileContent1
PARAMETER









8.Goto script tab in UI and add the following contents
var docArray = new Object();
function button1_Click(eventObject)
{


var uploadRequest = documentStoreRequest.XMLDocument;
uploader.request = uploadRequest;
uploader.setShowStatus(true);
uploader.uploadFile();
}
9.Preview the form.

For hiding a coulmn in a table @ runtime

APPA_USER_LEVEL_AUTH_MAT_LOCTable.hideColumn(0);

Populate or generate two text fields based on the already given data

(we have to check the details given by the user in textbox is existing ,if it is so we want to populate our text boxes from the same table which we are checking .if it is not there in the table then we have to check with other table, if the contents are no there in the second table also then we have to simply leave ..)

function generateupperlowerlimit()
{

if((expense_category1.getValue()!="")&&(expense_subcategory.getValue()!="")&&(employee_id1.getValue()!=""))
{
var req = GetAppaUserLevelAuthforUpperLowerObjectModel.getMethodRequest();
cordys.setTextContent(cordys.selectXMLNode(req,".//*[local-name()='EMPLOYEE_ID']"),employee_id1.getValue());
cordys.setTextContent(cordys.selectXMLNode(req,".//*[local-name()='EXPENSE_CATEGORY_CODE']"),expense_category1.getValue());
cordys.setTextContent(cordys.selectXMLNode(req,".//*[local-name()='EXPENSE_SUBCATEGORY_CODE']"),expense_subcategory.getValue());
GetAppaUserLevelAuthforUpperLowerObjectModel.setMethodRequest(req);
GetAppaUserLevelAuthforUpperLowerObjectModel.reset();


if((cordys.selectXMLNodes(GetAppaUserLevelAuthforUpperLowerObjectModel.getData(),".//*[local-name()='tuple']").length>0)&&(user_auth_matrix_id1.getValue()==""))
{
var upper1=cordys.getNodeText(GetAppaUserLevelAuthforUpperLowerObjectModel.getData(),".//*[local-name()='UPPER_LIMIT']","","");
var lower1=cordys.getNodeText(GetAppaUserLevelAuthforUpperLowerObjectModel.getData(),".//*[local-name()='LOWER_LIMIT']","","");
upper_limit1.setValue(upper1);
lower_limit1.setValue(lower1);
application.notify("User Authorization already defined for this combination");

}
else
{

var req2 = GetAppaExpenseAuthMatrixUpperLowerObjectModel.getMethodRequest();
cordys.setTextContent(cordys.selectXMLNode(req2,".//*[local-name()='DEPT_LONGNAME']"),dept_longname.getValue());
cordys.setTextContent(cordys.selectXMLNode(req2,".//*[local-name()='DESG_NAME']"),desg_name.getValue());
cordys.setTextContent(cordys.selectXMLNode(req2,".//*[local-name()='EXPENSE_CATEGORY']"),expense_category1.getValue());
cordys.setTextContent(cordys.selectXMLNode(req2,".//*[local-name()='EXPENSE_SUB_CATEGORY']"),expense_subcategory.getValue());
cordys.setTextContent(cordys.selectXMLNode(req2,".//*[local-name()='ACTIVE']"),"Y");
cordys.setTextContent(cordys.selectXMLNode(req2,".//*[local-name()='STATUS']"),"Approved");

GetAppaExpenseAuthMatrixUpperLowerObjectModel.setMethodRequest(req2);
GetAppaExpenseAuthMatrixUpperLowerObjectModel.reset();
if(cordys.selectXMLNodes(GetAppaExpenseAuthMatrixUpperLowerObjectModel.getData(),".//*[local-name()='tuple']").length>0)

{
var upper=cordys.getNodeText(GetAppaExpenseAuthMatrixUpperLowerObjectModel.getData(),".//*[local-name()='UPPER_LIMIT']","","");
var lower=cordys.getNodeText(GetAppaExpenseAuthMatrixUpperLowerObjectModel.getData(),".//*[local-name()='LOWER_LIMIT']","","");

upper_limit1.setValue(upper);

lower_limit1.setValue(lower);
}

}





}
}

Checking inside the table if same records are selected by the user with the help of same field

function checksamelocationtype()
{
for(i=1;i<=APPA_USER_LEVEL_AUTH_MAT_LOCTable.getRows().length;i++)
{
for(j=i+1;j<=APPA_USER_LEVEL_AUTH_MAT_LOCTable.getRows().length;j++)
{
if(branch_code[i].getValue()!="")
{
if(branch_code[i].getValue()==branch_code[j].getValue())
{
application.notify("Same Branch Code is chosen more than once");

}
}
if(region_code[i].getValue()!="")
{
if(region_code[i].getValue()==region_code[j].getValue())
{
application.notify("Same Region Code is chosen more than once");

}

}
if(cluster_code[APPA_USER_LEVEL_AUTH_MAT_LOCTable.getIndex()].getValue()!="")
{
if(cluster_code[i].getValue()==cluster_code[j].getValue())
{
application.notify("Same Cluster Code is chosen more than once");

}

}



}

}
}

For getting the table field value

Tablefieldid[tableid.getIndex()].getValue()

Example:

cluster_code[APPA_USER_LEVEL_AUTH_MAT_LOCTable.getIndex()].getValue()