Thursday, May 28, 2009

Share Records programmatically

Few days back our client placed a new requirement that he needs the newly created lead needs to to be shared by all the team mates of the businessunit, and that needs to be done automatically. I thought a workflow on lead creation will do the job. But when I sit on the system and to my surprise found that there is no option in the workflow manager for the same. I started scratching my head and at last decided to write a plugin for the same. Now instead of writing everything from scratch I asked the same to my good old friend (GOOGLE) :-) and i was really surprised to get this post by David Fronk of Dynamic Methods Inc. He explained everything in such detail that ...... it starts looking like a kid's play.

With all credit to his great job the excerpts of the post is :

Most implementations just open things up at the business unit level, or even the global level (depending on the size of the company) and don't even worry about sharing. However, there are times when certain information can be sensitive and necessary to restrict access to. Typically these things can be activities, opportunities, cases, services billed, hours worked, etc.


For instance, suppose sales reps aren't allowed to see support cases but are allowed to see the accounts that they manage. Any good account manager would want to know what support issues their account has been having before engaging on a new business proposal, so obviously the sales rep should get to see the cases related to the account.


All that is required is a couple of plugins at two main points and upon creation of a case and reassignment of an account. Whenever a case is created, get the account manager of the account on the case and share the case with that user. If the account gets reassigned, remove the share from the old account manager and add rights to the new account manager. Now with simple logic you can make data more accessible to those who should see the data without them having to do anything more than their regular job.


One side note, be aware that the more items there are under a parent record the longer the reassignments of records will take. For instance, if I reassign an account with 50 cases that's going to take a lot longer to complete the reassignment than it would if there were 5 cases, or even none. Just keep that in mind as you develop your sharing solution.


Pretty simple, and the SDK has some great examples on how to do this. Look up "AccessRights Enumeration", "GrantAccess Message", and "RevokeAccess Message" in the SDK and you should have everything you need.


Here's a quick example on how to share and give all rights to a user:





SecurityPrincipal principal = new
SecurityPrincipal();
principal.Type = SecurityPrincipalType.User;
principal.PrincipalId = new
Guid("7B222F98-F48A-4AED-9D09-77A19CB6EE82");
PrincipalAccess access = new
PrincipalAccess();
access.Principal = principal;
access.AccessMask = AccessRights.ReadAccess;

TargetOwnedDynamic target = new
TargetOwnedDynamic();
target.EntityId = new
Guid("6A92D3AE-A9C9-4E44-9FA6-F3D5643753C1");
target.EntityName = "incident";

GrantAccessRequest readGrant = new
GrantAccessRequest();
readGrant.PrincipalAccess = access;
readGrant.Target = target;
GrantAccessResponse readGranted = (GrantAccessResponse)crmService.Execute(readGrant);

access.AccessMask = AccessRights.WriteAccess;
readGrant.PrincipalAccess = access;
GrantAccessResponse writeGranted = (GrantAccessResponse)crmService.Execute(readGrant);

access.AccessMask = AccessRights.AppendAccess;
readGrant.PrincipalAccess = access;
GrantAccessResponse appendGranted = (GrantAccessResponse)crmService.Execute(readGrant);

access.AccessMask = AccessRights.AppendToAccess;
readGrant.PrincipalAccess = access;
GrantAccessResponse appendToGranted = (GrantAccessResponse)crmService.Execute(readGrant);

access.AccessMask = AccessRights.AssignAccess;
readGrant.PrincipalAccess = access;
GrantAccessResponse assignGranted = (GrantAccessResponse)crmService.Execute(readGrant);

access.AccessMask = AccessRights.DeleteAccess;
readGrant.PrincipalAccess = access;
GrantAccessResponse deleteGranted = (GrantAccessResponse)crmService.Execute(readGrant);



And here is an example on how to revoke access:





SecurityPrincipal principal = new
SecurityPrincipal();
principal.Type = SecurityPrincipalType.User;
principal.PrincipalId = new
Guid("7B222F98-F48A-4AED-9D09-77A19CB6EE82");
PrincipalAccess access = new
PrincipalAccess();
access.Principal = principal;
access.AccessMask = AccessRights.ReadAccess;

TargetOwnedDynamic target = new
TargetOwnedDynamic();
target.EntityId = new
Guid("6A92D3AE-A9C9-4E44-9FA6-F3D5643753C1");
target.EntityName = "incident";
GrantAccessRequest readGrant = new
GrantAccessRequest();
readGrant.PrincipalAccess = access;
readGrant.Target = target;
GrantAccessResponse readGranted = (GrantAccessResponse)crmService.Execute(readGrant);

Override the tool tip of the field in Dynamics CRM

there are times when you want to give your users more information into what they should enter into a field.

As widely accepted the tooltips are the most commonly used and convenient way to achieve the same.

In Dynamics CRM you could use scripts to override the tool tip of the field.

Here's the code script to override the tool tip of the field in dynamics CRM:





var oPopup = window.createPopup();
var oPopupBody = oPopup.document.body;
oPopupBody.style.fontFamily = 'Tahoma';
oPopupBody.style.border = '1px solid black';

function showPopupMessage (Tool_Tip_Text)
{
oPopupBody.innerHTML = "
";
oPopupBody.innerHTML += "
" + Tool_Tip_Text +"
";
var X_Coordinate= -100;
var Y_Coordinate= 20;
var width = 350;
var height = 90;
var documentElement = event.srcElement;
oPopup.show(X_Coordinate, Y_Coordinate, width, height, documentElement);
}

//Be sure to attach your OnMouseOver event with the field's caption

crmForm.all.new_customfield1_c.attachEvent('onmouseover', showPopupMessage ("custom tooltip for new_customfield1 "));
crmForm.all.new_customfield2_c.attachEvent('onmouseover', showPopupMessage ("custom tooltip for new_customfield2 "));
crmForm.all.new_customfield3_c.attachEvent('onmouseover', showPopupMessage ("custom tooltip for new_customfield3 "));


Now you can hover your mouse over the field labels to see your custom tooltip popup

CRM 4 Certification Practice Tests

Hi all,

Richard recently authored practice test questions for the three core CRM 4 certification exams. he is having LOTS of other articles on the exams and how to prepare for them in the certification category. So if you are thinking of clearing the MB 631 , MB 632 or MB 633 you must visit this place.

you can test your knowledge with these practice test here

i have gone through the tests and it is really great. try your knowledge there and best of luck :-)

How to Convert lead to contact, account and/or opportunity programmatically

Sometime we need to convert a lead to a contact, account and/or opportunity programmatically. to achieve this we have to follow the below mentioned process:

it is a two step process. in the first step we need to disable the lead. This can be done by using the SetStateLeadRequest. In the second step we need to use the InitializeFromRequest and InitializeFromResponse classes. It's the InitializeFromRequest class in which we will need to set the EntityMoniker attribute to the lead which you just disabled in the first step. On the same request we'll need to set the target entityname to the name of the entity we wish to convert the lead into (contact, account or opportunity) and then we'll need to set the TargetFieldType. This would most likely be TargetFieldType.All. Now execute that request and here we go .

code example: in this example we will create a function to convert a lead into account programmatically


// <summary>
// Convert Lead To Account
// </summary>
// <param name="service">CrmService</param>
// <param name="leadID">Guid of the Lead that needs to be converted</param>
// <returns>Guid of ctreated account</returns>
public Guid convertLeadToAccount(CrmService service, Guid leadID)
{
//step one : qualify the lead
SetStateLeadRequest qualifier = new SetStateLeadRequest();
qualifier.EntityId = leadID;
qualifier.LeadState = LeadState.Qualified;
qualifier.LeadStatus = -1;
service.Execute(qualifier);
//Note: lead is qualified, but not converted to account yet

InitializeFromRequest req = new InitializeFromRequest();
// this is the very thing that does the job.
req.EntityMoniker = new Moniker();
req.EntityMoniker.Id = leadID;
req.EntityMoniker.Name = "lead";
req.TargetEntityName = EntityName.account.ToString();
req.TargetFieldType = TargetFieldType.All;
InitializeFromResponse rps = (InitializeFromResponse)service.Execute(req);
Guid AccountID = service.Create(rps.Entity);
return AccountID;
}

Monday, May 18, 2009

How to Create a Dynamic IFRAME

Change the Page Displayed in the IFRAME
You may want to change the target of the IFRAME based on considerations such as the data in the form or whether the user is working offline. You can set the target of the IFRAME dynamically.
Note When you change the URL for the IFRAME, parameters are not passed to the new URL automatically. You need to append the querystring parameters to the URL before setting the src property.
Example
The following code example shows you how to set the src for the IFRAME and pass the parameters.


var params = crmForm.all.IFRAME_test.url;
params = params.substr(params.indexOf('?'));
var newTarget = "http://mysite/mypage.aspx";
newTarget = newTarget + params;
crmForm.all.IFRAME_test.src = newTarget ;


Allow Access to Form Data
If you trust the target site of the IFRAME you can disable the security attribute so cross-frame scripting is enabled. This allows the target page to reference or change data in the entity form.


A script in the target of the IFRAME can access objects in the parent. The crmForm cannot be referenced by name because it does not have an ID associated with it, but it is the first form in the forms collection.
For example, to set the value of a variable named AccountName to the name of the Account, use the following code in a page that is the target of an IFRAME in the account form:


var AccountName = parent.document.forms[0].all.name.DataValue;


This value, or any other value in the form, can then be processed by the Web page that is the target of the IFRAME.
The Web page that is the target of the IFRAME can also update the crmForm field values, as shown in the following code example:

parent.document.forms[0].all.name.DataValue = AccountName;


Note : Scripts in Microsoft Dynamics CRM cannot interact with DHTML elements within the IFRAME. This is a security restriction that is set within Internet Explorer for all IFRAME elements.

Reading field values from a lookup

Here is how the value of a lookup field can be retrieved :


crmForm.all.lookupfield.DataValue[0].name
//gives us the name of the lookup field's selected record.

crmForm.all.lookupfield.DataValue[0].id
//gives us the GUID of the lookup field's selected record.

Tuesday, April 14, 2009

Filtering lookup data in CRM 4

Its a common need for most of the customers to have the filtered lookup fields on the form instead of the current general lookup fields.

while i was browsing on some of my favourite blogs i found a brilient post regarding the same.

while the solution is non microsoft supported , it works for me.

Kudos to George Doubinski for this post
Filtering lookup data in CRM 4

Happy Hacking

Tuesday, February 10, 2009

How to call javascript functions from a custom menuitem

In the previous post we learned how to add custom menus. Now sometimes we need to call some custom functions for some information processing. So for that we can write a javascript function and call that javascript function from the MenuItem click.

for example: we added a MenuItem "Custom JavaScript function" at our desired entity location and wish to call our custom function Myfunction on MenuItem click
so we need to modify the ISV.config as mentioned below:


<MenuItem JavaScript="Myfunction()">
<Titles>
<Title LCID="1033" Text="Custom JavaScript function" />
</Titles>
</MenuItem>


Now place your function in the entity onload event and expose the Myfunction function to the page level e.g. this.Myfunction = Myfunction;


function Myfunction()
{
//Place Your logic Here...
}

this.Myfunction = Myfunction;




Now when you click on the MenuItem "Custom JavaScript function" the function Myfunction will be called.

Adding Custom Menu items

MSCRM provides liberty to add your own CustomMenu to cater your customized needs.
for that purpose all you need to do is to edit the ISV.config file located at path /_Resources/.
This is an xml file so we can say what you all need to do is to customize this xml to suit your needs and you are done.

To add a custom menu MSCRM provides CustomMenu tag that can be introduced in the ISV.config at the following locations:
  1. The MenuBar element inside the Grid can contain an ActionMenu element and one or more Button elements.
  2. The MenuBar element inside the Root or entity element can contain a CustomMenus element.



Adding Action Menu Links to Grid:


<grid>
<menubar>
<actionsmenu>
<menuitem title="required link 2" url="http://www.yourdomain.com/desiredfilenew.aspx" winmode="1">
<menuspacer>
</actionsmenu>
<buttons>
<button title="Test" tooltip="custom button" url="http://www.yourdomain.com/desiredActionfile.aspx" winmode="2" icon="/_imgs/ico_18_debug.gif">

<toolbarspacer>
</buttons>
</menubar>
</grid>




Adding Menu Links to Entities:


<entities>
<entity name="account">
<menubar>
<custommenus>
<menu title="Custom Menu">
<menuitem title="my file" url="http://www.yourdomain.com/desiredfile.aspx" validforupdate="1" validforcreate="0" availableoffline="false">
</menu>
</custommenus>
</menubar>
</entity>
</entities>



Adding Menu Links to Root

<!-- The main Global Menu Bar located at the top of all root level areas -->
<MenuBar>
<!-- Custom Menus that appear between the Goto Menu and the Help Menu -->
<CustomMenus>
<Menu>
<Titles>
<Title LCID="1033" Text="ISV" />
</Titles>
<MenuItem Url="http://www.microsoft.com">
<Titles>
<Title LCID="1033" Text="New Window" />
</Titles>
</MenuItem>
<MenuSpacer />
<!-- A horizontal drop down menu spacer -->
<SubMenu>
<Titles>
<Title LCID="1033" Text="ISV Tests" />
</Titles>
<MenuItem Url="http://www.microsoft.com" WinMode="2">
<Titles>
<Title LCID="1033" Text="Modeless Dialog" />
</Titles>
</MenuItem>
<MenuSpacer />
<MenuItem Url="http://www.microsoft.com" WinMode="1">
<Titles>
<Title LCID="1033" Text="Modal Dialog" />
</Titles>
</MenuItem>
<MenuSpacer />
<MenuItem JavaScript="alert('test');">
<Titles>
<Title LCID="1033" Text="Custom JavaScript" />
</Titles>
</MenuItem>
</SubMenu>
</Menu>
</CustomMenus>
</MenuBar>

Monday, February 2, 2009

Error messages in CRM

Most of us while working on CRM, faces error codes returns by CRM. CRM does give you error messages every now and then. The message is usally in the format of "0x12345678". The numbers do not tell much, but the corresponding error message do help you definitely. These error messages are given in the SDK and on a lot of places on the internet, but there the "0x" has been removed from the error message. Here is the same list as which is listed in the SDK, but now with the included 0x, posted by Ronald in his blog.

Do you wanna get rid of "Do you want to close this window?"

I always got this annoying question whenever i opened CRM untill I found the below mentioned code posted by Ronald Lemmen on his blog post here , but its no more now, cheers to Ronald.
You might get a question everytime you open CRM in Internet Explorer.
The question is:
The webpage you are viewing is trying to close the window.
Do you want to close this window?
yes no
This message does appear in CRM 4.0 only when you are using
Internet Explorer 7.0 and you have enabled the application mode setting. Nevertheless, it is an anoying message which you can get away!To get rid of this
message:
open the default.aspx file which resides in the root of the CRM website.
In this file there are these three lines of code:

var oMe = window.self;
oMe.opener =
window.self;
oMe.close();

Modify the second line of this snippet
and end up with these three lines:

var oMe =
window.self;
oMe.open('','_self','');
oMe.close();


You now will not have the message anymore.
Note:Keep in mind that any update or migration might remove this change, but you should be able to reapply the change easily again.

Metadata Browser

The Metadata Browser is a set of web pages which lets you view an Organization’s Entities, Attributes and Relationships.
You can see a quick overview of the metadata for your organization by using the metadata browser. This live view of the metadata, which shows only published information, is found here:

http://yourservername[:port]/yourorganizationname/sdk/list.aspx

You can use this to view the definition for all entities and attributes in your organization, both system and custom.
If you click an icon in the Definition column, you will see a view of all the attributes in the selected entity. At the top of this view you can view the ownership type of the entity, its type code, whether it is customizable, and if it is valid for Advanced Find.
For each attribute you can view its type, whether it is valid for create, update, and retrieve operations, and so on.

Retrieving the Web Service Version

The Web service version is needed to support ISV applications that can easily detect and work with multiple versions of Microsoft Dynamics CRM. The RetrieveVersion message provides support for determining the version, or build number, of the Microsoft Dynamics CRM software installed on the server.
Example : The following code retrieves the version of the server software and produces output like this: "4.0.7283.0"



// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

RetrieveVersionRequest versionRequest = new RetrieveVersionRequest();
RetrieveVersionResponse versionResponse = (RetrieveVersionResponse)service.Execute(versionRequest);
Console.WriteLine(versionResponse.Version.ToString());

CRM Web Services

Microsoft Dynamics CRM 4.0 provides a dynamic Web service interface for applications to use to access and manipulate platform data as well as interact with platform services. These services allow ISVs to write applications using Microsoft Visual Studio or other developer tools by simply referencing the platform Web service. The Web services exposed by the platform are WSI BP 1.1 compliant. This compliance support makes the Web services interoperable with non-Microsoft platforms.
The Microsoft Dynamics CRM SDK includes the following Web services:
1. Discovery Web Service (DiscoveryService.asmx)
2. CRM Web Service (CrmService.asmx)
3. Metadata Web Service (MetadataService.asmx)
The Discovery Web service is a mechanism to find the correct CrmService endpoint for your organization or to obtain a CRM ticket for Internet-facing deployment (IFD) or for Microsoft Dynamics CRM Online.
The CRM Web service provides strongly typed access to all entities in Microsoft Dynamics CRM, including custom entities and attributes. This Web service also allows execution of all supported operations, including those with built-in business logic as well as specialized operations. It provides a valid Web Services Description Language (WSDL) that is dynamically generated on the server to include the latest customizations and provides a single endpoint for your code.
The Metadata Web service provides methods to read and write the metadata for an organization. This includes the definitions for entities, attributes, and relationships.
In Microsoft Visual Studio 2005, you use the Add Web Reference command to point to the Web services. After the Web reference has been added to your project, all of the Web methods and classes in the Web service's namespace are available in your project.
For more information about Web services, see The Microsoft Web Services Developer Center msdn.microsoft.com/webservices/. You can also read the article "XML Web Services Basics" here

Custom Entities

A custom entity is a business entity whose schema is created through the customization tools in the Microsoft Dynamics CRM Web application or by using the Metadata Web service. This feature enables you to provide important extensions to support vertical business requirements. It also makes building on the Microsoft Dynamics CRM platform easier, enabling ISVs, for example, to produce solutions that integrate seamlessly with Microsoft Dynamics CRM.
Custom Entity Life Cycle
Create
– The schema is created and an empty form is published.
Update - Schema changes are saved to the metadata but UI changes remain unpublished.
Publish - UI changes are published and are visible in the application.
Delete - Schema changes and the UI is changed immediately, no publish step is needed.
When you create a custom entity using the Web application, you enter the schema name for the entity. This name is used to create the logical name and the filtered view name.

Custom entities also support the following functionality:

You can create forms, views, and reports to expose your new entities in Microsoft Dynamics CRM.
You can publish, export, and import these new entities and their associated forms and views.
You can include these new entities in the dataset that Microsoft Dynamics CRM for Microsoft Office Outlook users can take offline.
You can secure these new entities in the same manner as other Microsoft Dynamics CRM entities.
The security privileges available for organization-owned custom entities are as follows: create, read, write, delete, append, and append to.
The security privileges available for user-owned custom entities are as follows: create, read, write, delete, append, append to, assign, and share.
You can define relationships for custom entities.
Callouts for custom entities function in the same manner as for system entities.
Client-side events function in the same manner as those for system entities.
Custom entities can be extended using the ISV.config file in the same manner as system entities.
The filtered views for custom entities are available to be used in the same manner as for system entities.

Accessing the Server Using the Web Service

Accessing the Server Using the Web Service
Methods are called by first creating an instance of the Web service. In Microsoft Visual Studio 2005, Microsoft IntelliSense support is provided on the Web service methods. To access the server, you may need to specify the URL as shown here for the CrmService.
Example
The following is a simple example accessing the Web service. For a complete set of samples for different authentication scenarios, see Web Service Security and Impersonation.



// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();
service.Url = "http://<servername>[:<port>]/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

The Web references to the Microsoft Dynamics CRM Web services define a default value for the service's URL property. These default URL values contain the Web service addresses for the Microsoft Dynamics CRM server that was used when you created the Web references. If you need to point your application at a different Microsoft Dynamics CRM server at run time, you must set the CrmService.Url property to the address of the Web services on that server.
Note As a best practice, you can store the URL of the Microsoft Dynamics CRM server in the application configuration file for your custom code.
If you wish to run your code against a Microsoft Dynamics CRM server on a different domain, you cannot use the default network credentials. You must define valid domain credentials for the domain that has Microsoft Dynamics CRM access rights. Alternatively, you can establish a trust between the two domains.

Important You must assign a CrmAuthenticationToken value to the Microsoft Dynamics CRM Web service instance before calling Web service methods. Failure to do so results in an HTTP 401 error when the Web service methods are called.

GenerateAuthenticationHeader

The GenerateAuthenticationHeader function retrieves a properly formed Microsoft Dynamics CRM authentication header. This authentication header automatically determines the appropriate authentication type to use for each deployment type: on-premise, IFD, or Microsoft Dynamics CRM Online. Note that the SOAP header for IFD does not include information about the CrmTicket because a session-based ticketing system is used. For more information, see Authentication.

Each XMLHttp request requires a <soap:Header>
Example
You can generate this header for your code by using the following function:
GenerateAuthenticationHeader();
Without this function you would need to define a SOAP header in your code like the one here for the on-premise version:

<soap:Header>
<CrmAuthenticationToken xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<AuthenticationType xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
0
</AuthenticationType>
<OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
AdventureWorksCycle
</OrganizationName>
<CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
00000000-0000-0000-0000-000000000000
</CallerId>
</CrmAuthenticationToken>
</soap:Header>

CRM SDK Assemblies

The Microsoft Dynamics CRM SDK includes the following assemblies:
Microsoft.Crm.Sdk.dll
This assembly contains the base classes needed to develop custom workflows and workflow activities. It also contains helper classes which can be used when you develop plug-ins and workflows.
Microsoft.Crm.SdkTypeProxy.dll
This assembly contains types needed when you develop plug-ins and custom workflows. These include the request/response classes and a set of methods that are used for instantiating CRM types can be found in Microsoft.Crm.SdkTypeProxy.CrmTypes.
This assembly also includes the same set of entity classes, such as account class. However, these are for internal use only. When you work with entity instances, you should use the Microsoft.Crm.Sdk.DynamicEntity class or add the CrmService WSDL to your code and use the entity classes found there.
See Microsoft.Crm.SdkTypeProxy Namespace for reference documentation on this assembly.
Microsoft.Crm.Outlook.Sdk.dll
This assembly contains methods and types needed for customizing Microsoft Dynamics CRM for Microsoft Office Outlook.
See Microsoft.Crm.Outlook.Sdk Namespace for reference documentation on this assembly.
Microsoft.Crm.Tools.EmailProviders.dll
This assembly contains methods and types needed for developing a custom E-mail Provider component for the Microsoft Dynamics CRM E-mail Router.
See Microsoft.Crm.Tools.Email.Providers Namespace for reference documentation on this assembly.
Both 32-bit and 64-bit versions of these assemblies can be found in the SDK\Bin folder of the SDK download. The download is located at go.microsoft.com/fwlink/?LinkID=102966.
If you are running in a 32-bit process, use the 32-bit assemblies. If you are running in a 64-bit process, use the 64-bit assemblies.
For synchronous plug-ins, use the version that matches the Microsoft Dynamics CRM server.
For custom workflow activities and asynchronous plug-ins, use the version that matches the Asynchronous service.
For client applications and add-ins, use the version that matches the Web application or Microsoft Dynamics CRM for Outlook.
For Microsoft Dynamics CRM Online, use the version that matches the Web application or Microsoft Dynamics CRM for Outlook.

Saturday, January 31, 2009

How to add lookup field in an entity

There are times when we need to select a value from a set of values.

Now the set of values may be fixed or might not be fixed (that is coming from another table or in other words some dynamic set of values are there)

Now for these two options we have two solutions: Picklist or Lookup

Picklists are mostly used when we have a fixed or defined set of values but for dynamic values or picking values from a table, we can use custom entity and add it as a lookup to our form.

Now to achieve this we just need to create a 1:N relationship in the Table entity to the entity which we want the lookup to be. By Table entity,I mean the table that which we need to display in lookup.

1. Go to : Settings->Customization->Customize entities.

2. Create a new entity for the new table data.

3. Every entity has a primary field. This field gets shown up in the lookup. Name this field appropriately.

4. Publish this entity.

5. Now double click any other entity, where we would want the lookup.

6. In the left navigation pane, we'll find N:1 relationships.Create an N:1 relationship with the entity created in step 2.

7. Now go to forms and views on the same entity. Click on Main Form.

8. Select 'Add fields'.

9. Add the required lookup field.

10. Publish the changes.

11. Populate the entity created in step 2 with data and say cheers as its done.