xml NSOA:设置项目留言板内容
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml NSOA:设置项目留言板内容相关的知识,希望对你有一定的参考价值。
<platform_solution><objects><text_area_cust_field><divider_text></divider_text><name>prj_accomplishments</name><never_copy>false</never_copy><rows>3</rows><description>Accomplishments</description><with_notes>false</with_notes><required>false</required><hint></hint><field_width>75</field_width><hidden>false</hidden><title>Accomplishments</title><association>project</association><divider>false</divider></text_area_cust_field><text_area_cust_field><divider_text></divider_text><name>prj_benefit</name><never_copy>false</never_copy><rows>3</rows><description>Benefit</description><with_notes>false</with_notes><required>false</required><hint></hint><field_width>75</field_width><hidden>false</hidden><title>Benefit</title><association>project</association><divider>false</divider></text_area_cust_field><text_area_cust_field><divider_text></divider_text><name>prj_changes</name><never_copy>false</never_copy><rows>3</rows><description>Changes</description><with_notes>false</with_notes><required>false</required><hint></hint><field_width>75</field_width><hidden>false</hidden><title>Changes</title><association>project</association><divider>false</divider></text_area_cust_field><pick_list_cust_field><divider_text></divider_text><name>prj_department</name><never_copy>false</never_copy><description>Owning Department</description><with_notes>false</with_notes><list_source>department</list_source><hint></hint><hidden>false</hidden><title>Owning Department</title><association>project</association><divider>false</divider></pick_list_cust_field><url_cust_field><never_copy>false</never_copy><target>_blank</target><required>false</required><url>[Click to access](https://www.openair.com)</url><association>project</association><divider_text></divider_text><unique>false</unique><name>prj_external_link</name><description>External Link</description><with_notes>false</with_notes><hint></hint><title>External Link</title><hidden>false</hidden><divider>false</divider></url_cust_field><text_area_cust_field><divider_text></divider_text><name>prj_objective</name><never_copy>false</never_copy><rows>3</rows><description>Objective</description><with_notes>false</with_notes><required>false</required><hint></hint><field_width>75</field_width><hidden>false</hidden><title>Objective</title><association>project</association><divider>false</divider></text_area_cust_field><pick_list_cust_field><divider_text>Background</divider_text><name>prj_sponsor</name><never_copy>false</never_copy><description>Project Sponsor</description><with_notes>false</with_notes><list_source>user</list_source><hint></hint><hidden>false</hidden><title>Project Sponsor</title><association>project</association><divider>true</divider></pick_list_cust_field><checkbox_cust_field><divider_text></divider_text><name>prj_message_refresh</name><never_copy>false</never_copy><description>Force message board refresh</description><with_notes>false</with_notes><checked>false</checked><hint>Check to refresh all message board content on Save</hint><hidden>false</hidden><title>Force message board refresh</title><association>project</association><divider>false</divider></checkbox_cust_field><form_script><custom_fields><custom_field>prj_sponsor</custom_field><custom_field>prj_department</custom_field><custom_field>prj_external_link</custom_field><custom_field>prj_objective</custom_field><custom_field>prj_benefit</custom_field><custom_field>prj_accomplishments</custom_field><custom_field>prj_changes</custom_field><custom_field>prj_message_refresh</custom_field></custom_fields><name>setMessageBoardContent.nsoa.js</name><event>after_save</event><libraries></libraries><comments>Initial commit</comments><entrance_function>main</entrance_function><parameters></parameters><__is_linked>true</__is_linked><association>project_edit_form</association><code><![CDATA[function main(type) {
var needsUpdate = false;
var needsReset = false;
var newRec = NSOA.form.getNewRecord();
if (type == 'new') {
needsUpdate = True;
} else if (type == 'edit') {
var oldRec = NSOA.form.getOldRecord();
if (
(oldRec.prj_sponsor__c !== newRec.prj_sponsor__c) ||
(oldRec.prj_department__c !== newRec.prj_department__c) ||
(oldRec.prj_external_link__c !== newRec.prj_external_link__c) ||
(oldRec.prj_objective__c !== newRec.prj_objective__c) ||
(oldRec.prj_benefit__c !== newRec.prj_benefit__c) ||
(oldRec.prj_accomplishments__c !== newRec.prj_accomplishments__c) ||
(oldRec.prj_changes__c !== newRec.prj_changes__c)
) {
needsUpdate = true;
}
}
if (newRec.prj_message_refresh__c == 1) {
needsUpdate = true;
needsReset = true;
}
NSOA.meta.log('debug', 'main<br>needsUpdate=' + needsUpdate);
if (needsUpdate) {
var attr = {name: 'update_custom', value: 1};
var objPrj = new NSOA.record.oaProject();
objPrj.id = newRec.id;
var jsonData = getData(newRec);
objPrj.message = getHTML(jsonData);
if (needsReset) {
objPrj.prj_message_refresh__c = '';
}
var results = NSOA.wsapi.modify([attr], [objPrj]);
NSOA.meta.log('debug', 'main<br>results=' + JSON.stringify(results));
}
}
function getData(recPrj) {
NSOA.meta.log('debug', 'getData<br>recPrj.id=' + recPrj.id);
var data = {};
// customer data
var recCus = NSOA.record.oaCustomer(recPrj.customerid);
var reWeb = /(http|https):\/\/[^ "]+/; // find http(s) in a URL string
var mWeb = reWeb.test(recCus.web);
data.website = (mWeb === true) ? recCus.web : 'http://' + recCus.web; // super hack for strange URL requirements
data.aboutus = recCus.cus_aboutus__c;
// contact data
var conID;
if (recPrj.billing_contactid) {
conID = recPrj.billing_contactid;
} else {
conID = recCus.billing_contact_id;
}
var recCon = NSOA.record.oaContact(conID);
data.contactname = recCon.addr_first + ' ' + recCon.addr_last;
data.contactrole = recCon.job_title;
// link data
var fldUrl = recPrj.prj_external_link__c;
var reUrl = /\[(.*)\]\(((?:ftp|http|https):\/\/[^ "]+)\)/; // simple URL validation check
var mUrl = reUrl.exec(fldUrl);
data.siteurl = mUrl[2];
data.sitetext = mUrl[1];
// project data
data.objective = recPrj.prj_objective__c;
data.benefit = recPrj.prj_benefit__c;
data.accomplishments = recPrj.prj_accomplishments__c;
data.changes = recPrj.prj_changes__c;
// user data
var recUsr = NSOA.record.oaUser(recPrj.prj_sponsor__c);
data.sponsorname = recUsr.addr_first + ' ' + recUsr.addr_last;
// role data
var recRol = NSOA.record.oaRole(recUsr.role_id);
data.sponsorrole = recRol.name;
// department data
var recDep = NSOA.record.oaDepartment(recPrj.prj_department__c);
data.department = recDep.name;
// cost center data
var recCos = NSOA.record.oaCostcenter(recPrj.cost_centerid);
data.costcenter = recCos.name;
NSOA.meta.log('debug', 'getData<br>data=' + JSON.stringify(data));
return data;
}
function getHTML(jsonData) {
var content = '' +
'<div style="width:50%;position:relative;float:left;">' +
'<strong>Project Sponsor: </strong>{{sponsorname}}, {{sponsorrole}}<br>' +
'<strong>Owning Department: </strong>{{department}}<br>' +
'<strong>Cost Center: </strong>{{costcenter}}<br>' +
'<strong>External Link: </strong><a href="{{siteurl}}" target="_blank">{{sitetext}}</a>' +
'</div>' +
'<div style="width:50%;position:relative;float:left">' +
'<strong>Customer Contact: </strong>{{contactname}}, {{contactrole}}<br>' +
'<strong>Web: </strong><a href="{{website}}" target="_blank">{{website}}</a><br>' +
'<strong>About Us: </strong>{{aboutus}}' +
'</div>' +
'<hr>' +
'<strong>Objective:</strong><br>{{objective}}<br>' +
'<strong>Benefit:</strong><br>{{benefit}}' +
'<hr>' +
'<strong>Accomplishments:</strong><br>{{accomplishments}}<br>' +
'<strong>Changes:</strong><br>{{changes}}<br>' +
'<hr>' +
'<p style="font-size:8px">Last updated: ' + getTimestamp() + '</p>' +
'';
var output = content
.replace(/{{sponsorname}}/, jsonData.sponsorname || '')
.replace(/{{sponsorrole}}/, jsonData.sponsorrole || '')
.replace(/{{department}}/, jsonData.department || '')
.replace(/{{costcenter}}/, jsonData.costcenter || '')
.replace(/{{siteurl}}/, jsonData.siteurl || '')
.replace(/{{sitetext}}/, jsonData.sitetext || '')
.replace(/{{contactname}}/, jsonData.contactname || '')
.replace(/{{contactrole}}/, jsonData.contactrole || '')
.replace(/{{website}}/g, jsonData.website || '')
.replace(/{{aboutus}}/, jsonData.aboutus || '')
.replace(/{{objective}}/, jsonData.objective || '')
.replace(/{{benefit}}/, jsonData.benefit || '')
.replace(/{{accomplishments}}/, jsonData.accomplishments || '')
.replace(/{{changes}}/, jsonData.changes || '')
;
return output;
}
function getTimestamp() {
var options = {
timeZone : 'America/New_York',
timeZoneName : 'short',
weekday : 'long',
year : 'numeric',
month : 'short',
day : '2-digit',
hour : '2-digit',
minute : '2-digit',
second : '2-digit'
};
return new Date().toLocaleString('en-US', options);
}]]></code></form_script></objects><version>1.1</version><title>Set Project Message Board Content</title><description>Sets the content of the project message board based on project standard and custom fields.</description></platform_solution>
以上是关于xml NSOA:设置项目留言板内容的主要内容,如果未能解决你的问题,请参考以下文章