CRM 2011 - Form onload, transfer field data to entity - dynamics-crm-2011

I've set up contacts in leads successfully but when a user adds a new contact it wont auto fill in the parent lead field i created to link the contact to the lead.
Does anyone one know what script i could use onload that will auto fill a filed on the lead called Parent Lead. It needs to update the contact field with the leads primary account.
Hope that makes sense.
At the moment the user has to find the lead through the custom lookup field.

Check your relationship ... 1to1, 1tomany, manytomany?
here is the code to populate a lookup field anyway:
var value = new Array();
value[0] = new Object();
value[0].id = idValue;
value[0].name = textValue;
value[0].entityType = typeValue;
Xrm.Page.getAttribute("fieldName").setValue(value);

Related

Change default PO form for a role based on condition

I have a requirement where I need to default certain fields on the PO form if the particular PO is created from MRP. I have created a summary field which will result data if the PO is created from a planned order. Now I need to default certain fields only for a role in this case. I was thinking of creating another custom form and defaulting all the fields using a workflow and call it only when the summary field has a value. The defaulting should not happen in other cases.
Please advice on the best approach on this, I am not much proficient in scripting yet.
Thanks
You can do this either via script or workflow,In case of a workflow default the values of the fields with the condition of your summary field and the role.If you want to do it in script something like this will help you
var userObj = runtime.getCurrentUser();
log.debug("Internal ID of current user role: " + userObj.role);
var userObj = runtime.getCurrentUser();
log.debug("Custom script ID of current user role: " + userObj.roleId);

Workaround to search Netsuite Note record by Customer id

I'm trying to get an app I'm working on to display all associated user notes for a given Customer record (as it appears on the UI Customer record page in Netsuite proper).
To that end, I've set up a Netsuite RESTlet to return a list of internal ids for associated Note records given a Customer internal id.
I've set up a simple search in the RESTlet script:
function get_notes(params) {
log("GET params", JSON.stringify(params));
var filters = [
new nlobjSearchFilter('internalid', 'customer', 'is', params.id)
];
var columns = [
new nlobjSearchColumn('internalid'),
new nlobjSearchColumn('note'),
];
var search = nlapiCreateSearch('note', filters, columns);
var notes = search.runSearch().getResults(0, 3);
return notes;
}
function log(msg, details) {
nlapiLogExecution('DEBUG', msg, details);
}
The script works as expected, but the problem is that this search ONLY returns Notes for which the author field (which is a user internal id) matches the internal id of the user performing the search. Meaning - you can only search for Notes for which you are the author.
I have been informed that this is a 'feature' of Netsuite for some unfathomable security reason.
I need to be able to get a list of all the associated Note ids, not just those for which the user making the request is the author.
Any ideas on a workaround to get at all the associated Notes? A different way to structure the search? Some kind of secret way to define your own custom Search Joins?
I can't even find documentation on this behavior (blocking Note searches from non-authors). Perhaps someone knows how to override it at the admin level?
I'm not quite ready to admit that this is impossible yet.
NB: User Note is a Note-type record associated with the Customer record, not a field on Customer record, so I can't access it directly from Customer. There is also not a Search Filter or Search Join for Note or User Note.
Using RESTlets you cannot get the notes of other users unless you invoke the RESTlet using credentials/tokens of roles like Administrator/Full Access. RESTlets always runs in the context of current user.
One alternative to do that, if you really got to achieve this any how:
1) Create a user event script on customer which creates a custom record that simulates the functionality of system notes.
2) Make sure that the RESTlet user roles have full level of access on the custom record and make customer as parent of your custom record.
3) In your RESTlet return the custom records.
Basically RESTLETS always run as the user who invokes them.
If you can use a Suitelet for this you can set that up to run as Administrator and can return any Notes you can craft a search for.
Are you actually needing a Restlet ? i.e. Are you calling this from an external application or are you trying to add functionality in the NS GUI? If the latter then you can easily use a Suitelet.

Issue while inserting the user in liferay

I have created a form which has basic user details and on clinking of the Save button I am inserting the user details in the "USER_" table by calling the UserLocalServiceUtil.addUser(....). Now the user is creating with out any issue. But I am not able to see some form field parameters in UserLocalServiceUtil.addUser(....) method like (Title, Gender and Date Of Birth). Now how can I save this values. Please give me some suggestions that how can I insert the following fields (Title, Gender and Date Of Birth) at the time of user creation.
Liferay uses com.liferay.portal.model.Contact entity to store the contact information.
Use com.liferay.portal.service.ContactLocalServiceUtil.addContact method to create the contact. Significant parametres:
userId - Id of the user that is creating the contact. You can use PortalUtil.getUser method to get the current user from a request.
className - "com.liferay.portal.model.User".
classPK - Id of the new user that the contact is created for.

How to add value to a field from another lookup field?

I have a custom entity Partnership in which I have one lookup field contacts.
now I want to add the name field value of the partnership from contact fullname in time of creation of Partnership.
is it possible with the help of pre-existing configuration settings,(without plugin or web resource)
Thanks.
Without using a plug-in or web resource you have a couple options.
1- You can configure the mappings between the 2 entities by going to the Entity (contact) -> Relationship -> Mappings -> and add a new mapping there. For this to work though, you will need to create the child record from the subgrid of the contact, and if the contact changes it won't update the values. So it may or may not be an ideal solution for you.
2- You can create a workflow rule that runs on create and/or update of the Partnership record that pulls the value from the parent contact onto the partnership record. The downside of this is that workflows are async so you won't see the update for a few seconds and refresh the Partner record.
Hope this helps.
If you want to be able to click the "New Partnership" button in the CRM ribbon, then select a contact, and have the name of the contact, be used to populate another field on the form, you will have to use JavaScript. There is no configurable way of doing it.
If you'd like the value to be populated before it is saved in the CRM database, you could use JavaScript, or a custom Plugin. If you'd like the value to be updated after the record is created, you could use a workflow.
You'll have to use one of those three methods to populate the field. The real question I have though, is why are you bothering to populate the field in the first place? You can add the full Contact name to any view, so I don't see a real big reason to include it.

How to properly set lookup value in CRM 2011? I'm only getting halfway

After a lot of scouring for answers and experimenting I finally managed to put together something that doesn't end in complete fail. It can be seen below.
// set value in form field
function setLookup(lookupSchemaName, lookupGuid, lookupValue, lookupEntity)
{
//var lookupSchemaName = 'uomid';
//var lookupGuid = '270BD3DB-D9AF-4782-9025-509E298DEC0A';
//var lookupValue = 'EACH';
//var lookupEntity = 'unit';
Xrm.Page.getAttribute(lookupSchemaName).setValue([{id: lookupGuid, name: lookupValue, entityType: lookupEntity}]);
}
This is attached to the onChange event of the product lookup field. It works but not completely. The problem is that when it runs I end up with a lookup field that contains the word 'EACH' and is highlighted in blue (indicative of a link being made with the record behind it; see image below) but is not fully accepted. It's a state of limbo so to speak.
What I expect to get is the entity's icon and a clickable value. I'm also unable to save the form but I can use the regular lookup function for the field and get things back to normal.
The issue here is that you are using the display name for Unit of Measure and not the logical name.
The correct logical name for Unit of Measure is uom.
This can be found in CRM by going
Settings > Customisations > Customise the System > Entities
The logical name is displayed on the entity page.

Resources