how to add "sendemail" button in gridView of customized entity in crm - dynamics-crm-2011

There is one customized entity named as "Add to Campaign" . Since there is no default "Email" button in sub-grid , so i placed one customized button and provided javascript to open Email form , and the Email form opens good.
But now the problem is , cant able to get selected records "Email field" in "Send to field" in Email Form.
so how to get selected record email to be displaced in "Email Form"

Open the email form with parameters:
Xrm.Utility.openEntityForm("email", null, param);
var param = {}; // passed as parameters to the new email form
if(Xrm.Page.getAttribute("-- LogicalNameOfField --") // make sure that the field has a value
param["-- LogicalNameOfFieldInNewEmail --"] = Xrm.Page.getAttribute("-- LogicalNameOfField --"); // passes a field value to the new form
// This passes a lookup field as a parameter to the new form
if(Xrm.Page.getAttribute("-- LogicalNameOfLookup --").getValue() != null) { // make sure that the lookup field is not empty or we will have a problem trying to access [0].id and [0].name
param["-- LogicalNameofLooupFieldInEmail --"] = Xrm.Page.getAttribute("-- LogicalNameOfLookup --").getValue()[0].id;
param["-- LogicalNameOfLookup --" + "name" (eg. "accountname")] = Xrm.Page.getAttribute("-- LogicalNameOfLookup --"].getValue()[0].name;
Xrm.Utility.OpenEntityForm("LogicalEntityName", null, param); // open the form and pass parameters
Take note of how the lookup field is passed as a parameters:
2 parameters are passed for each lookup field
The GUID as the name of the lookup field (account if account if the name of the lookup field in the new email)
The name of the lookup in the source entity as a special parameter (accountname)
Note: there is no field called "accountname", but there is a field called "account" in this hypothetical entity

Related

Ho do I implement the property converter for value providers in RAD data Form

I have a RAD data form in my nativescript-angular app. The form has two fields for ID type and ID number. The ID type field is a picker that displays data from a backend service. My source Object looks like:
this.mySourceObj = new User("Passport Id", "A2653JHSJ12");
I want my source object to store the value of the ID type as a string.
So I changed the editors using HTML markup, like:
<TKEntityProperty
tkDataFormProperty
name="idType"
displayName="Id Type"
index="1"
[valuesProvider]="idTypesProvider"
>
<TKPropertyEditor
tkEntityPropertyEditor
type="Picker"
></TKPropertyEditor>
</TKEntityProperty>
and in my ts file I register my valueproviders like:
this.idTypesProvider = {
key: "id",
label: "name",
items: [...idTypesArr]
};
With this set, my picker editor gets populated with the data but when I select one item, it does not reflect in my code so at the time of form submission the field is null.
I would like to get the value of the selected item as a complete object i.e. (id, name, ...).
I have tried using the property committed event to get the committed value but it is logs an index value of the item.
if (args.propertyName === "idType") {
const selectedIdType = this.mySourceObj.idType;
console.log(`the committed id type is :`, selectedIdType);
} else {
console.log("No property selected");
}
I have also come across the property convert that is attatched in the dom like:
<TKEntityProperty
tkDataFormProperty
name="idType"
displayName="Id Type"
index="1"
[converter]="valsConverter"
[valuesProvider]="idTypesProvider"
>
<TKPropertyEditor
tkEntityPropertyEditor
type="Picker"
></TKPropertyEditor>
</TKEntityProperty>
But I do not know how to implement the "Converter". Any help is highly appreciated.
I want a situation where when the user selects an ID type, my console can log The complete object of the selected Item.

NetSuite: How do I populate a custom transaction field with the ship-to custom address field

In NetSuite, how do I populate a custom transaction field
(custbody_site_no_shipto)
on a transaction (for example, a Sales Order) with a custom address field
(custrecord_site_no)
for the Ship-To Address selected (under the Shipping tab)?
Custom transaction field: custbody_site_no_shipto
(Menu: Customization > Lists, Records, & Fields > Transaction Body Fields – Display Type is Inline Text).
Custom address field: custrecord_site_no
(Menu: Customization > Lists, Records, & Fields > Other Custom Fields – Checked Apply To All Custom Address Forms).
Usually, you would configure the sourcing of the custom field on the 'Sourcing and Filtering'.
However, shipping address is not included the 'Source List'.
So to cater that requirements, you might only do automation/customization either by SuiteFlow or SuiteScript (Client Side or User Event script).
And looking to your requirements, it seems you can only do this using after submit user event script. It is because the "Address" you wanted to access is a subrecord and not all APIs for it can be used on client side script. I have example below:
var recSO = nlapiLoadRecord('salesorder', 34826,
{
recordmode : 'dynamic'
});//34826 is the internal id of SO
var recSubAddress = recSO.viewSubrecord('shippingaddress');//Ship To field id
var stSiteN0 = recSubAddress.getFieldValue('custrecord_site_no');
recSO.setFieldValue('custbody_site_no_shipto', stSiteN0);
var stRecId = nlapiSubmitRecord(recSO);
The script below works and was implemented as a User Event Script.
function userEventBeforeSubmit(type) {
var shipadd = nlapiGetFieldValue('shipaddresslist');
var customer = nlapiGetFieldValue('entity');
var record = nlapiLoadRecord('customer', customer,{recordmode: 'dynamic'});
var linenum = record.findLineItemValue('addressbook', 'internalid', shipadd);
record.selectLineItem('addressbook', linenum);
var subrecord = record.viewCurrentLineItemSubrecord('addressbook', 'addressbookaddress');
var customfield1 = subrecord.getFieldValue('custrecord_site_no');
nlapiSetFieldValue('custbody_site_no_shipto', customfield1);
}

How to create a Custom Select List for a netsuite field?

I have a field on a custom record. The name of the field is reference_code.
I want to populate "reference_code" with my own dynamic list which would be presented as a drop down to the user.
How do I do this? I defined my field as Free-Text. Do I need to keep it hidden but then show it as a drop down before I load the form?
I thought this might do something:
nlapiInsertSelectOption('custrecord_rulereferencecode', code, code, false)
But I would need to convert the field to a select?
Typically, instead of creating the field as Free-Text, you would first create a Custom List (Customization > Lists/Records/Fields > Lists > New) with all of your dropdown options.
Then you would create your field as a List/Record field and select your new Custom List as the "List/Record Type", as depicted below.
This can be done by giving a source to your drop-down menu. The source field accepts an internal id of a list. This internal id can be an in-built(provided by netSuite) or a custom list created by a user. For Eg: I have a custom list with an internal id '23' which has some list items in it, these can be populated in the drop down menu by the following syntax.
var start = function(request, response)
{
var form = nlapiCreateForm('Custom Form');
form.addField('custpage_selectfield', 'select', 'select a color', '23');//here 23 is the internal id of my list
respnose.writePage(form);
}
or you could generate you own field's dynamically using the addSelectOption() function.
var start = function(request, response)
{
var form = nlapiCreateForm('Custom Form');
var myselectfield = form.addField('custpage_selectfield', 'select', 'select a color');
myselectfield.addSelectOption('1', 'Red');//Here 1, 2 and 3 are the id's
myselectfield.addSelectOption('2', 'Green');//which are returned when the
myselectfield.addSelectOption('3', 'Blue');//form is submitted
respnose.writePage(form);
}
I solved this by creating two fields. One is created in the RecordType and will store the info. I set this as hidden. The next field, with the custom dropdown is added in user event. I then process data for my custom dynamic select list and add that to my added user event field.
Then in my change event, I set the record type field to the value selected in my dynamically added field.
Userevent
function userEventBeforeLoad(type, form, request){
if(type == "edit"){
form.addField('custpage_referencecode','select','Reference Code',null, null)
}
}
In my Client Script:
function clientFieldChanged(type, name, linenum){
if(name == 'custpage_referencecode'){
//obtain the upper case value
var codetext = nlapiGetFieldValue(name)
//make sure it hasn't been set
if (codetext != nlapiGetFieldValue('custrecord_rulereferencecode'))
{
nlapiSetFieldValue('custrecord_rulereferencecode', codetext );
}
}
return true
}

Get view name in xpages view control

I'm using a view control to display a notes view. We are also using a search function, to search the first column of each view. As we want to save the search parameter a user has entered, we've created a bean saving the search key for each user.
To save the seach key, we are using this code in the data > keys property of a view control:
var dbName:String = database.getFilePath();
var viewName:String = "vwCurrentRequests";
var searchValue:String = searchUserBean.getSearchValue(dbName+viewName);
if(searchValue.isEmpty() || searchValue==null) {
return "";
} else {
return searchValue;
}
But we always have to define the viewName value for each view. So the question is: How can we get the view name of the current view?
You can access the name of the view with this SSJS code:
getComponent("viewPanel1").getData().getViewName()
viewPanel1 is the id of your view panel.
EDIT:
As Frantisek Kossuth wrote, you can use the this keyword instead of the getComponent.
this.getData().getViewName()

Sharepoint List redirect with new id

I have a list within Sharepoint, using a custom new form I have added a custom list form control ("New item form" for the list) and changed the SaveButton to a standard input HTML button, and added an 'onclick' event that is as follows:
onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={NewFormWizard2.aspx?id=}')}"
This works as in saves the data and redirects to the NewFormWizard2.aspx?id= page.
How do I get the ID of the created item to be passed to the redirected page?
Thus once the form is completed it would redirect to NewFormWizard2.aspx?id=23
jtherkel was close, but was missing a '}' on the end of the redirect url. I used an extra concat below
<input type="button" value="Submit" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={lists/MyListName/DispForm.aspx?ID=',/dsQueryResponse/Rows/Row/#ID,'}'))}" />
I am not sure where the ID will exist on the page you host the Javascript from. Does it appear in the querystring or on a field on the page?
There is nothing in the request or response that will identify the item. I have had this issue when doing some web loadtesting.
I can only suggest that your create the item using the webservices as that at gives you some return xml.
This answer does not solve the "new form" issue, but it might help others with the syntax for screens that contain existing list items.
I tested this quickly in my SharePoint (MOSS 2007) environment.
onclick="javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={NewFormWizard2.aspx?id=',/dsQueryResponse/Rows/Row/#ID))}"
The concat syntax is an XSLT instruction that tells the processor to combine the values enclosed in single quotes. I adapted this answer from info I found here.
Loading Values in a Custom List Form
http://wssdevelopment.blogspot.com/2007_04_01_archive.html
I hope this would be helpfull:
1- In SharePoint Designer create new page, call it for example "LastItem.aspx" and place a dataview on it with a single form view for the destination list item.
2-Limit paging to just one record, set the sorting by ID and descending and filter the list to just show item which is created by [current user].
3-Now you do not need to pass any query string to this page. just replace the default "OK" button in NewForm.aspx of the list with a standard HTML input button and add this to its definition "onclick="javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={LastItem.aspx}". After submitting a new item to list you will be redirected to an edit view of the created item.
You can do the same for save button in LastItem.aspx to redirect to some other page after clicking on save button.
found an approach using pure javascript (JQuery) and the SPAPI code from http://darrenjohnstone.net/.
The list contains two fields, title and BodyCopy
I've thewn created a form that asks for a title and a question, both text fields, then the submit button calls the following function: (note that ServerAddress and LIST_question need to be updated to your own details).
The function then uploads the details using the SOAP service within LISTS.ASMX and using the response gets the ID of the new item and redirects the page.
var LIST_question = '{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}';
var ServerAddress = 'http://xxx/';
function submitQuestion()
{
var title = new String($("#title").val());
var t = new String($("#question").val());
t=t.trim();
if(t=="")
return;
title=title.trim();
if(title=="")
return;
var lists = new SPAPI_Lists(ServerAddress) ;
//
var newItem = { Title : title, BodyCopy : t};
var items = lists.quickAddListItem(LIST_question, newItem);
var id=-1;
if (items.status == 200)
{
var rows = items.responseXML.getElementsByTagName('z:row');
if(rows.length ==1)
{
var r = rows[0];
var id = r.getAttribute('ows_ID');
window.location.href='DispForm.aspx?ID='+id;
}
else
{
alert("Error: No row added");
}
}
else
{
alert('There was an error: ' + items.statusText);
return;
}
}
You can achieve this using JavaScript http://www.sharepointdrive.com/blog/Lists/Posts/Post.aspx?ID=9

Resources