GRN_Email_Notification

PHOTO EMBED

Tue Jan 07 2025 15:14:21 GMT+0000 (Coordinated Universal Time)

Saved by @Pooja

void GRN.GRN_Email_Notification(int ID)
{
	getgrnsubform = GRN_Subform[GRN_ID == input.ID];
	//info getgrnsubform;
	getgrnmain = GRN[ID == getgrnsubform.GRN_ID];
	//info getgrnmain;
	getposubform = Purchase_Order_Subform[ID == getgrnsubform.Purchase_Order_SubForm_RECID];
	//info getposubform;
	getpomain = Purchase_Order[ID == getposubform.Purchase_Order_ExisID];
	//info getpomain;
	//	getindentsf = Indent_Sub_Form[ID == getposubform.Indent_Sub_Form];
	getindentsf = Indent_Sub_Form[Purchase_Order_Subform_RECID == getgrnsubform.Purchase_Order_SubForm_RECID];
	//info getindentsf;
	getindent = Indent[ID == getindentsf.Indent_Form_RECID];
	//info "Get Indent:" + getindent;
	getindentor = Employee_Details[ID == getindent.Request_Raised_By];
	emailto = getindentor.Employee_Email;
	//info "Email To:" + emailto;
	getemail = Email_Template[Template_No == 3];
	sub = getemail.Subject_field;
	body = getemail.Body;
	sub = sub.replaceAll("{grnno}",getgrnmain.Goods_Received_Note_Number,true);
	sub = sub.replaceAll("{pono}",getpomain.Purchase_Order_No,true);
	body = body.replaceAll("{indentor}",ifnull(getindentor.Employee_Name,""),true);
	body = body.replaceAll("{grnno}",getgrnmain.Goods_Received_Note_Number,true);
	tab = "<html><style>th,td {padding: 5px;}</style><table border = 1> <th>Indent No.</th>  <th>Part No.</th> <th>Part Description</th> <th>Specification</th> <th>Quantity Received</th><th>UOM</th> <th>Remarks of Indent</th> <th>Purpose of Indent</th> <th>Zoho Project</th>";
	for each  tablerec in getgrnsubform
	{
		getindentno = Indent_Sub_Form[Purchase_Order_Subform_RECID == tablerec.Purchase_Order_SubForm_RECID];
		getuom = Unit_of_Measurement[ID == tablerec.UoM].UOM;
		if(getindentno.count() > 0)
		{
			IndentLink = "<a href='https://creatorapp.zoho.in/carrierwheels/erp#Report:All_Indents?Indent_No=" + ifnull(getindentno.Indent_No,"") + "' title='Click to Open Indent' target='_blank'>" + ifnull(getindentno.Indent_No,"") + "</a>";
			tab = tab + "<tr><td>" + ifnull(IndentLink,"") + "</td>";
			tab = tab + "<td>" + tablerec.Part_No.Part_No + "</td>";
			tab = tab + "<td>" + tablerec.Part_Description.Part_Description + "</td>";
			tab = tab + "<td>" + ifnull(tablerec.Specification,"") + "</td>";
			tab = tab + "<td>" + ifnull(tablerec.Received_Qty,0) + "</td>";
			tab = tab + "<td>" + getuom + "</td>";
			myindentsf = Indent_Sub_Form[Purchase_Order_Subform_RECID == tablerec.Purchase_Order_SubForm_RECID];
			tab = tab + "<td>" + ifNull(myindentsf.Remarks,"") + "</td>";
			tab = tab + "<td>" + ifNull(myindentsf.Purpose_of_Indent,"") + "</td>";
			tab = tab + "<td>" + ifnull(myindentsf.Project_Name,"") + "</td></tr>";
		}
		else
		{
			//info "else";
			IndentLink = "<a href='https://creatorapp.zoho.in/carrierwheels/erp#Report:All_Indents?Indent_No=" + ifnull(getindentno.Indent_No,"") + "' title='Click to Open Indent' target='_blank'>" + ifnull(getindentno.Indent_No,"") + "</a>";
			//info "Link:" + IndentLink;
			tab = tab + "<tr><td>" + IndentLink + "</td>";
			tab = tab + "<td>" + tablerec.Part_No.Part_No + "</td>";
			tab = tab + "<td>" + tablerec.Part_Description.Part_Description + "</td>";
			tab = tab + "<td>" + ifnull(tablerec.Specification,"") + "</td>";
			tab = tab + "<td>" + ifnull(tablerec.Received_Qty,0) + "</td>";
			tab = tab + "<td>" + getuom + "</td>";
			myindentsf = Indent_Sub_Form[Purchase_Order_Subform_RECID == tablerec.Purchase_Order_SubForm_RECID];
			tab = tab + "<td>" + ifNull(myindentsf.Remarks,"") + "</td>";
			tab = tab + "<td>" + ifNull(myindentsf.Purpose_of_Indent,"") + "</td>";
			tab = tab + "<td>" + ifnull(myindentsf.Project_Name,"") + "</td></tr>";
		}
	}
	//info "Tab:" + tab;
	tab = tab + "</table></html>";
	body = body.replaceAll("{table}",tab,true);
	//info "Body:" + body;
	//emp = Employee_Details[Department_Name.Department_Name == "Stores"];
	if(getindentno.count() > 0)
	{
		sendmail
		[
			from :"CWPL ERP<erp@carrierwheels.com>"
			to :emailto
			cc:"sourcing@carrierwheels.com"
			reply to :"stores@carrierwheels.com"
			subject :sub
			message :body
		]
	}
	else
	{
		sendmail
		[
			from :"CWPL ERP<erp@carrierwheels.com>"
			to :"sourcing@carrierwheels.com"
			cc:"sourcing@carrierwheels.com"
			subject :sub
			message :body
		]
	}
	//cc:"sourcing@carrierwheels.com"
}
content_copyCOPY