Quantcast
Channel: Forum CRM Development
Viewing all 1000 articles
Browse latest View live

Refresh parent form after subgrid record is added

$
0
0

I have a plugin that gets triggered after a subgrid record is added to a parent form. This plugin modifies fields in the parent form.

How can I refresh the parent form to show my new field values after a record is added to the grid on a parent form?

Thanks

Phil


(CRM 2011 Rollup 13)

Probleme with related entities inside FetchXml query

$
0
0

Hi Everybody,

I met a problem about the construction of a FetchXML query :

My need is to get the result of this SQL Query : 

SELECT DISTINCT Contact.ContactId
FROM Contact
LEFT OUTER JOIN grd_contact_ensemble
        INNER JOIN grd_ensemble
            ON grd_ensemble.grd_ensembleId = grd_contact_ensemble.grd_ensembleid   
    ON Contact.ContactId = grd_contact_ensemble.Contactid
LEFT OUTER JOIN grd_address
        INNER JOIN grd_communecp
            ON grd_communecp.grd_communecpId = grd_address.grd_PostalCodeId
    ON Contact.ContactId = grd_address.grd_ContactId
WHERE 
grd_ensemble.grd_code = 'A04024'
OR
grd_communecp.grd_cp LIKE '91220%'
OR 
grd_communecp.grd_cp LIKE '05%'

I tried to write somthing like this, but it seems that the usage of relation into fetch xml are limited:
In fact the clause WHERE OR between attributes of differents ralated entities seems to be impossible ?

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" ><entity name="contact" ><attribute name="contactid" /><link-entity name="grd_address" from="grd_contactid" to="contactid" alias="ae" link-type="outer" ><link-entity name="grd_communecp" from="grd_communecpid" to="grd_postalcodeid" alias="af" ><filter type="and" ><filter type="or" ><condition attribute="grd_cp" operator="like" value="91220%" /><condition attribute="grd_cp" operator="like" value="05%" /></filter></filter></link-entity></link-entity><link-entity name="grd_contact_ensemble" from="contactid" to="contactid" visible="false" intersect="true" link-type="outer" ><link-entity name="grd_ensemble" from="grd_ensembleid" to="grd_ensembleid" alias="ag" ><filter type="and" ><condition attribute="grd_code" operator="eq" value="A04024" /></filter></link-entity></link-entity></entity></fetch>

Do you have any ideas about this issue ?

Thx in advance for your precious help :)

Kya

CRM 2011: How can I show a hidden web resource using JScript?

$
0
0

Quick one: How can I show a hidden web resource using JScript?

I tried

Xrm.Page.ui.controls.get("WebResource_name").setVisible(true);

but it didn't work...

Thanks for the help!

P.

Table for users in MS Dynamics CRM 4.0

$
0
0

Hi All

I need to know the SQL to extract users of my MS Dynamics CRM 4.0 application by querying SQL server database for CRM application when I dont want to go through Active Directory.

Thanks in advance

:)

SQL for User Info with Roles in MS Dynamics CRM 4.0?

$
0
0

Hi All

How to form a SQL to get users information along with roles assigned to them in MS Dynamics CRM 4.0?

Or can anyone share the table name where mapping between SystemUserBase and RoleBase is present?

cheers

What is the master table to know AccessMode?

$
0
0

Hi All

SystemUserBase table has one field with the name "Accessmode" and values are like 0 and 2. I would know the master table so that I know what they exactly means.

thank you very much in advance.

Cheers

close Incident plugin

$
0
0

I try to update the field "new_caseresolvedon" on the case form when the case is closed but i get this error:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: ---------->>>>>> ERROR 2System.InvalidCastException:Unable to cast object of type 'Microsoft.Xrm.Sdk.EntityReference' to type 'Microsoft.Xrm.Sdk.Entity'.
   at OnCaseClosedUpdateResolvedOn.UpdateResolvedOn.Execute(IServiceProvider serviceProvider)Detail: 
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
  <ErrorCode>-2147220891</ErrorCode>
  <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
    <KeyValuePairOfstringanyType>
      <d2p1:key>OperationStatus</d2p1:key>
      <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value>
    </KeyValuePairOfstringanyType>
  </ErrorDetails>
  <Message>----------&gt;&gt;&gt;&gt;&gt;&gt; ERROR 2System.InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Sdk.EntityReference' to type 'Microsoft.Xrm.Sdk.Entity'.
   at OnCaseClosedUpdateResolvedOn.UpdateResolvedOn.Execute(IServiceProvider serviceProvider)</Message>
  <Timestamp>2013-04-17T14:00:10.2027842Z</Timestamp>
  <InnerFault i:nil="true" />
  <TraceText>

[OnCaseClosedUpdateResolvedOn: OnCaseClosedUpdateResolvedOn.UpdateResolvedOn]
[b16c4e1b-66a7-e211-801b-005056b1002a: OnCaseClosedUpdateResolvedOn.UpdateResolvedOn: Close of incident]


</TraceText>
</OrganizationServiceFault>

Could anyone help to find a way to  cast the object and get this working

The general configuration of the plugin is:

Message: Close

Primary entity: incident

Stage: pre-operation

Mode : synchronous

And the code is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk.Messages;

namespace OnCaseClosedUpdateResolvedOn
{
    public class UpdateResolvedOn : IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            IOrganizationService service = factory.CreateOrganizationService(context.UserId);

            if (context.InputParameters.Contains("IncidentResolution"))
            {
                Entity entity = (Entity)context.InputParameters["IncidentResolution"];

                try
                {
                    Entity ticket = (Entity)entity["incidentid"];
                    ticket["new_caseresolvedon"] = DateTime.Now;
                }
                catch (Exception ex)
                {
                    throw new InvalidPluginExecutionException("---------->>>>>> ERROR 2" + ex);
                }


            }
            else 
            {
                throw new InvalidPluginExecutionException("---------->>>>>> ERROR 1");
            }
        } //serviceProvider
    }
}
Thank you

CRM 2011 Plug-in Update (Post-Oper): retrieving and updating a single record

$
0
0

On Update of an <account> record, the plug-in must update a related record (new_port) having a one-to-one relationship with account through new_accountid.

The code below doesn't do it!
I debugged and the id parameter received by the method is correct.
Also, new_port was created as a custom Activity entity.

Any idea what am I doing wrong?

        private static void UpdateAccountPort(IOrganizationService service, Guid id)
        {
            try
            {
                using (var crm = new XrmServiceContext(service))
                {
                    var account = crm.AccountSet.Where(
                        a => a.AccountId == id).First();

                    var port = crm.new_portSet.Where(
                        p => p.new_accountid.Equals(id)).First();

                    port.Subject = account.Name;
                    port.new_territoryid = account.TerritoryId;
                    port.new_relationshiptypecode = account.CustomerTypeCode.Value;
                    port.new_accountorcontactownerid = account.OwnerId;
                    crm.Attach(port);
                    crm.UpdateObject(port);

                    crm.SaveChanges();
                }
            }
            catch (FaultException ex)
            {
                throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
            }
        }


Frank


Update plugin throws exception "The given key was not present in the dictionary"

$
0
0

Greetings.

I have a plugin to update entity B when entity A gets updated.
I registered this plugin with a step for Update, Post-Operation, Synchronous.
Any idea why the code below fails at the line "var id = entity.Id;" and throws an exception "The given key was not present in the dictionary"?

Thanks in advance for your help.

using System;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using Microsoft.Xrm.Sdk;
using Xrm;
using Microsoft.Xrm.Sdk.Query;
using System.Collections.Generic;

namespace Portfolio
{
    public class PortfolioUpdate : IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {
            IPluginExecutionContext context = (IPluginExecutionContext)
            serviceProvider.GetService(typeof(IPluginExecutionContext));

            Entity entity;

            // Check if the input parameters property bag contains a target
            // of the create operation and that target is of type Entity.
            if (context.InputParameters.Contains("Target") &&
            context.InputParameters["Target"] is Entity)
            {
                // Obtain the target business entity from the input parameters.
                entity = (Entity)context.InputParameters["Target"];

                // Verify that the entity represents a contact or an account.
                if ((context.MessageName != "Create" && context.MessageName != "Update") ||
                    (entity.LogicalName != "contact" && entity.LogicalName != "account")) { return; }
            }
            else
            {
                return;
            }

            try
            {
                IOrganizationServiceFactory serviceFactory =
                    (IOrganizationServiceFactory)serviceProvider.GetService(
                typeof(IOrganizationServiceFactory));
                IOrganizationService service =
                serviceFactory.CreateOrganizationService(context.UserId);

                var id = entity.Id;

                UpdateAccountPortfolio(service, id);
            }
            catch (FaultException<OrganizationServiceFault> ex)
            {
                throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
            }
        }


Frank

Javascript to populate lookup field crashing

$
0
0

Hi everyone,

What I have is a script for Account create/update that when the zipcode is entered it then auto-populates the sales Territory lookup.  Everything works fine and dandy; I enter the zip code, the lookup is filled, looks the same as if I were to manually select it from the list.

The problem is when I try to save the Account with the Territory that was selected and populated with Javascript I get a generic error and it doesn't let me save; if I was to manually select the Territory it does save.

Are there any known issues with populating a lookup with an entity through script?

Below is the small code section that actually adds it to the field

            var lookup = new Object();
            var lookupValue = new Array();
            //set values that will go into the lookup in the form
            lookup.id = territory;
            lookup.entityType = "territory";
            lookup.name = territoryName;
            lookupValue[0] = lookup;

            //set city and territory on the form
            Xrm.Page.getAttribute("territoryid").setValue(lookup);

Thanks

Silverlight Refresh/Reload

$
0
0

We have been using the following lines of code to reload a Silverlight Web resource on a form. The code is triggered by an onchange of a lookup field. Its been working well until Rollup 12 was applied.

We are now getting "Error: Object doesn't support property or method 'getSrc'"

var wrctr = Xrm.Page.ui.controls.get(""WebResource_SLDemo"");
if (wrctr != null)
    wrctr.setSrc(wrcontrol.getSrc());

Looks like Rollup 12 (Cross Browser Support) have removed the method getSrcfrom Web Resource controls.

Does anyone have any alternate code or ways to reload XAP Web Resource on a form?

 Thanks

Run plugin when Email status is Sent

$
0
0

Hi,

I am trying to write a plugin that will run when the email status is changed to "Sent" but when I register the plugin for the "SetState" message or the "SetStateDynamicEntity" message it never runs.

What should I do here?

Thanks,

Dor.

The authentication endpoint Username was not found on the configured Secure Token Service!

$
0
0

We have crm 2011 and IFD installed and working.  We are deploying some code that will update records.

we are gettting the following error message

The authentication endpoint Username was not found on the configured Secure Token Service!

Here is a sample of our code

/// <summary>

/// Get a connection to the CRM service proxy.

/// </summary>

/// <returns></returns>

private OrganizationServiceProxy GetCRMService()

{

    string crmUserName = String.Empty;

    string crmUserPassword = String.Empty;

    try    

    {

        MiscFunctions.ReportTimer("GetCRMService - Start");

        if (serviceProxy == null)

        {

            //Service URLs will come from app.config for RDC and web.config/rdmp.config for RDCWeb

            Uri OrgUri = new Uri(ConfigurationManager.AppSettings["CRMServiceURL"]);

            Uri DiscoUri = new Uri(ConfigurationManager.AppSettings["CRMDiscoveryURL"]);

            ClientCredentials localCredentials = new ClientCredentials();

            ClientCredentials deviceCredentials = new ClientCredentials();

            // Use a delegate user...

            if (ConfigurationManager.AppSettings["Outlook Location"] == "online")

            {

                crmUserName = String.Format(@"{0}\{1}",

                ConfigurationManager.AppSettings["CRMDomain"], ConfigurationManager.AppSettings["CRMUser"]);

                crmUserPassword = ConfigurationManager.AppSettings["CRMPassword"];

                #if !DEBUG

                //TODO - Remove this from release build...

                ErrorTrack.WriteMessage("UpdateOffline", "GetCRMService", String.Format("User: {0} | Password: {1}", crmUserName, crmUserPassword), false);

                #endif

                localCredentials.UserName.UserName = crmUserName;

                localCredentials.UserName.Password = crmUserPassword;

            }

            // Create the service...

            serviceProxy = new OrganizationServiceProxy(OrgUri, DiscoUri, localCredentials, deviceCredentials);

            // Return the service...

        }

        MiscFunctions.ReportTimer("GetCRMService - End");

        return serviceProxy;

    }

    catch (Exception ex)

    {

        ErrorTrack.WriteMessage(ex, "GetCRMService", true);

        return null;

    }

}

 

This appears to return a service proxy...

 

but this method fails:

public bool AddStoreVisit(Guid StoreVisitID, Guid StoreID, String Name, DateTime TimeStart, DateTime TimeEnd, String StoreVisitBy, int VisitType, string RDCVersion)

{

    try

    {

        MiscFunctions.InitTimer();

        if (IsOutLookReady())

        {

            MiscFunctions.ReportTimer("AddStoreVisit - Start");

            OrganizationServiceProxy service = GetCRMService();

            Entity sv = new Entity("cmg_storevisit");

            sv.Id = StoreVisitID;

            sv["cmg_name"] = Name;

            sv["cmg_storeid"] = new EntityReference("cmg_store", StoreID);

            if (TimeStart > DateTime.MinValue)

                sv["cmg_storevisitdate"] = TimeStart;

            if (TimeEnd > DateTime.MinValue)

                sv["cmg_storevisitend"] = TimeEnd;

            sv["cmg_storevisitedby"] = StoreVisitBy;

            sv["cmg_storevisittype"] = VisitType;

            sv["cmg_rdcversion"] = RDCVersion;

            try

            {

                service.Create(sv);

            }

            catch (System.Web.Services.Protocols.SoapException ex)    

            {

                ErrorTrack.WriteMessage("UpdateOffline", "AddStoreVisit(SoapFault)", ex.Message + ":" + ex.Detail.OuterXml, true);

                return false;

            }

            catch (Exception exSave)

            {

                ErrorTrack.WriteMessage("UpdateOffline", "AddStoreVisit", exSave.Message, true);  <--******* THIS IS THE ERROR CATCH

                return false;

            }

            return true;

        }

        else

        {

            return false;

        }

    }

    catch (System.Web.Services.Protocols.SoapException sex)

    {

        ErrorTrack.WriteMessage(sex, "AddStoreVisit", true);

        return false;

    }

    catch (Exception ex)

    {

        ErrorTrack.WriteMessage(ex, "AddStoreVisit", true);

        return false;

    }

}

 

Our code works when we do it in offline mode, but not on the CRM server.

we have tried the suggested fix described here: http://www.thinketg.com/Company/Blogs/11-10-25/CRM_2011_Authentication_Endpoint_Not_Found_Error_Resolution.aspx

but the error remains.  Most of the suggested fixes I find are in relation to the e-mail router or the outlook client, and I am not having any issue connecting either of these the the environment, so I know the discovery service works.

If we comment out the setting of the localcredentials like so:

 

//Service URLs will come from app.config for RDC and web.config/rdmp.config for RDCWeb

Uri OrgUri = new Uri(ConfigurationManager.AppSettings["CRMServiceURL"]);

Uri DiscoUri = new Uri(ConfigurationManager.AppSettings["CRMDiscoveryURL"]);

ClientCredentials localCredentials = new ClientCredentials();

ClientCredentials deviceCredentials = new ClientCredentials();

// Use a delegate user...

if (ConfigurationManager.AppSettings["Outlook Location"] == "online")

{

    crmUserName = String.Format(@"{0}\{1}",

    ConfigurationManager.AppSettings["CRMDomain"], ConfigurationManager.AppSettings["CRMUser"]);

    crmUserPassword = ConfigurationManager.AppSettings["CRMPassword"];

    //localCredentials.UserName.UserName = crmUserName;

    //localCredentials.UserName.Password = crmUserPassword;

}

// Create the service...

serviceProxy = new OrganizationServiceProxy(OrgUri, DiscoUri, localCredentials, deviceCredentials);

 

we now get: The authentication endpoint Kerberos was not found on the configured Secure Token Service!

"PrincipalObjectAttributeAccess" does not work

$
0
0

Hi!

I want to use the "PrincipalObjectAttributeAccess" in CRM 2011 Online to change the users rights on secured_field. At the moment I'm using this code:

                    PrincipalObjectAttributeAccess poaa = new PrincipalObjectAttributeAccess()

                        {

                            AttributeId = secured_field,

                            ObjectId = new EntityReference("contact", contactid),

                           PrincipalId = new EntityReference("systemuser", SystUserID),
                            ReadAccess = true,
                            UpdateAccess = true

                        };

                        service.Create(poaa);

I obtain the error, that PrincipalObjectAttributeAccess  could not be found because an assembly reference is missing or an using directive. I have put the same using directives and references as shown in the sample code in SDK (the sample code works SampleCode\CS\FieldSecurity\RetrieveUserSharedAttributePermissions.cs), but without success. Does anybody know or have an idea how to put it to work?

CRM 2011: Editable Subgrid

$
0
0

hy all

I have a custom entity with a 1:N Relationship to another custom entity (children) and I show the children on the parent in a subgrid. It would be very nice, if the user could edit directly the values in the grid.

Is there any possibility to achieve that?

Thanks for your help!

 

Kind regards,

Peter


object doesnt support property or method getselectoption on form onload

$
0
0

function Form_onload()
{

var selectedOptionSet = Xrm.Page.getAttribute("new_guideline12answer2");

alert(selectedOptionSet.getSelectedOption().text);   

alert(selectedOptionSet.getSelectedOption().value);
alert("hi");

           

}

this thows me an error "  object doesn't support property or method getSelectedOption

can someone help me solve this problem, am just trying to hide show tab depending on option selected.

CRM 2011 - Value cannot be null.\r\nParameter name: detail

$
0
0
Trying to create a simple winform app with below code... when I come to saving am getting an error "{"Value cannot be null.\r\nParameter name: detail"}"

Anyone knows what am doing wrong, something missing ???

System.ServiceModel.Description.ClientCredentials cre = new System.ServiceModel.Description.ClientCredentials();            cre.UserName.UserName = "WWW\\Administrator";            cre.UserName.Password = "ab.1234";                         _serviceProxy = new OrganizationServiceProxy(new Uri("http://win-bvjq2ghxbvn/XRMServices/2011/Discovery.svc"),                                                                    null,                                                                    cre,                                                                   GetDeviceCredentials());                                            _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());            IOrganizationService service = (IOrganizationService)_serviceProxy;                        Entity contact = new Entity("contact");            contact["lastname"] = "contact created using IOrganizationSerivce";                        service.Create(contact);

gusse.net

Query email by From field

$
0
0

Hi,

I am trying to get all the email messages sent by the address assigned to a queue. When I open the email I see the queue in the From field, but the Sender field value is populated with a user, so I can't use advanced find nor sql. Is there a way to solve this?

Thanks in advance


Zarko

Stuck on this OData, would appreciate some help

$
0
0

Hi guys, I'm having major problems with this OData/Jscript. I'm a beginner and have spent weeks trying to research and get this working. Essentially I have a custom Entity called "PhoneLog". In that entity I have two fields:

"PhoneLog Name" (new_phonelogname) -> Primary Key Field

"Call Charge" (new_callcharge) -> Currency field

My dataset for this entity is called: we_phonelogSet


In the Phone Activity record, from Accounts, I have a custom Lookup field called: "Logging Type" (new_loggingtype).

I also have another custom field in the Phone Activity form called "Charge" (new_charge) which is a currency type.

In the Phone Activity entity, I want to select the lookup field ("Logging Type" (new_loggingtype) and select a record from my custom Entity -PhoneLog Name, and have the Call Charge (new_callcharge) transferred over to thePhone Activity entity; Charge" (new_charge). 

So far all my attempts have not worked out. I would appreciate some help getting this going.

 


Changing the value of an option set based on the value of another option set

$
0
0

Hello all,

I'm a novice when it comes to JScript coding. 

The requirement is that when a user changes the label of the "new_priority" option set field on the Opportunity form to "high" or 100000002, then the label of the "new_pipeline" option set field on the same form change to "qualification" or 100000001. Thus I have the following code on the OnChange event of the "new_pipeline" field:

function SetValue()
{
Xrm.Page.getAttribute(new_priority).getValue();
if (new_priority == (100000002)
{
Xrm.Page.getAttribute(new_pipeline).setValue(100000001);
}
}

Looking forward to your feedback.

Thanks 

Viewing all 1000 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>