The Requested Resources was not found or you do not have sufficient permissions to view it - dynamics-crm-2011

Dynamics crm when retrieving value and updating it into another entity it showing like
The Requested Resources was not found or you do not have sufficient permissions to view it
i specified update ids like
enobj.Id=(Guid)context.OutputParameters["id"];
message:create
service :update on another entity
this is my code:
Query Expression query = new Query Expression();
query.EntityName = en.LogicalName;
query.ColumnSet = new ColumnSet("new_amount");
var x = service.RetrieveMultiple(query);
Entity enobj = new Entity("new_product");
int i = 0;
foreach (var item in x.Entities)
{
i = i + (int)item.Attributes["new_amount"];
enobj.Attributes["new_grandtotal"] = i;
}
enobj.Id=(Guid)context.OutputParameters["id"];
// en.Id = enobj.Id;
enobj.Id = en.Id;
service.Update(enobj);
message:create
service :update
i have two entites product and productlineitems
in productlineitems iam creating a record with the field amount 50 after creating that value.iam updating on product entity.
again i create productlineitem 2 with the value some 90.iam adding 50+90 =140
again lineitem 3 with the value. iam taking that on product entity
message:create --- productlineitems
service :update --- product

I think you are trying to update Product with Product Line Id. Try the following:
Replace
enobj.Id = en.Id;
With
// set the field name (key) based on what you got in system
enobj.Id = (Guid)en["new_productid"];
Also, Calling Context is set to Current user. So make sure that user have permissions to update Product.

Related

Netsuite Inventory Item Custom Fields Update

I am trying to figure out how to update a custom field on InventoryItem record in Netsuite. I can update regular fields, but can not seem to update anything
InventoryItem item = new InventoryItem();
WriteResponse response;
List<CustomFieldRef> oCustomFieldRefList = new List<CustomFieldRef>();
item.internalId = "9";
StringCustomFieldRef objStringCustomFieldRef = new StringCustomFieldRef();
objStringCustomFieldRef.internalId = "custitem_main_photo";
objStringCustomFieldRef.value = "http://www.google.com/test.jpg";
oCustomFieldRefList.Add(objStringCustomFieldRef);
item.customFieldList = oCustomFieldRefList.ToArray();
response = _nsService.update(item);
The status returned by the update call is Success. It just doesn't update the custom field. I've tried different fields and types, but nothing seems to save.
The internalId of the custom field is the numeric id, not the string id. Not sure why the documentation all shows the string id value, but using the number fixed the problem for me.
Instead of assigning internal Id, assign scriptId.
Turn this
objStringCustomFieldRef.internalId = "custitem_main_photo";
to this:
objStringCustomFieldRef.scriptId = "custitem_main_photo";

create a filter not a group filter

I am creating a custom module in Orchard , I would like to create a query programmatically.
string queryName= "Product";
var item = _orchardServices.ContentManager.New("Query");
item.As<TitlePart>().Title =queryName;
_orchardServices.ContentManager.Create(item, VersionOptions.Draft);
if (!item.Has<IPublishingControlAspect>() && !item.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable)
_orchardServices.ContentManager.Publish(item);
var queryPart = item.As<QueryPart>();
queryPart.ContentItem.ContentType = queryName;
string desc =" filter for the query";
string contentType = "CommonPart.ChannelID.";
var filterGroupRecord = new FilterGroupRecord();
var filterRecord = new FilterRecord()
{
Category = "CommonPartContentFields",
Type = contentType,
Position = 0,
};
filterRecord.State = "<Form><Description>" + desc + "</Description><Operator>Equals</Operator><Value>ChannelId</Value></Form>";
filterGroupRecord.Filters.Add(filterRecord);
queryPart.FilterGroups.Insert(0, filterGroupRecord);
the problem is that:I want set a filters of the query,not a filters group.
could you tell me how to improve my code?
Database structure and class declarations make it impossible. Why do you need it?
Update:
I means that you must use FilterGroupRecord at least one.
But when Query published that Filter Group will be created automatically if query have not yet Filter Group (see at QueryPartHandler). You should add your filters to this group. And not needed to create new group.
var existingFilterGroup = queryPart.FilterGroups[0];
existingFilterGroup.Filters.Add(filterRecord);
Update 2:
To avoid problems with draftable query (and several other potential problems Orchard CMS: Adding default data to fields and then querying them) it is better to move the calling Publish method to the end of your code and other part of your code should be left unchanged. And in your case would be better if you will always publish your query without checking IPublishingControlAspect and Draftable.

Dynamics CRM 2011 LinkEntities left join issue

How can I add a filter condition to the linked entity (for example email in this case)?
Added filter condition to the link criteria which is giving me the duplicate rows.
The equivalent sql query should look like this.
select distinct OpportunityId
from Opportunity o
left join Email e on e.RegardingObjectId = o.OpportunityId
where o.StateCode = 1 and o.StatusCode = 3
and e.RegardingObjectId is null
But the QueryExpression class is doing the following way.
select distinct opportunityid
from Opportunity o
left join Email e
on e.RegardingObjectId = o.OpportunityId
and e.RegardingObjectId is null
where o.StateCode = 1 and o.StatusCode = 3
The code:
ClientCredentials Credentials = new ClientCredentials();
Credentials.Windows.ClientCredential
= System.Net.CredentialCache.DefaultNetworkCredentials;
Uri OrganizationUri = ""
Uri HomeRealmUri = null;
OrganizationServiceProxy orgService
= new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null);
IOrganizationService _service = (IOrganizationService)orgService;
QueryExpression query = new QueryExpression();
query.Distinct = true;
query.EntityName = "opportunity";
query.ColumnSet = new ColumnSet(true);
FilterExpression filter1 = new FilterExpression();
filter1.FilterOperator = LogicalOperator.And;
filter1.AddCondition("statuscode", ConditionOperator.Equal,3);
filter1.AddCondition("statecode", ConditionOperator.Equal, 1);
query.Criteria = filter1;
LinkEntity linkEntity1 = new LinkEntity();
linkEntity1.JoinOperator = JoinOperator.LeftOuter;
linkEntity1.LinkFromEntityName = "opportunity";
LinkEntity1.LinkFromAttributeName = "opportunityid";
linkEntity1.LinkToEntityName = "email";
linkEntity1.LinkToAttributeName = "regardingobjectid";
query.LinkEntities.Add(linkEntity1);
FilterExpression filter2 = new FilterExpression();
The issue is here at this condition. I could use filter on the LinkCriteria but not on the query since it is linked entity.
filter2.AddCondition("regardingobjectid", ConditionOperator.Null);
query.LinkEntities[0].LinkCriteria = filter2;
EntityCollection result = _service.RetrieveMultiple(query);
Console.WriteLine(result.Entities.Count());
Console.ReadKey();
I'm not sure if the query posted is what you are looking for...
If it is, then you should be able to remove filter 2 and add to filter 1
filter1.AddCondition("opportunityid", ConditionOperator.Null);
But comparing the RegardingObjectId to both NULL and the OpportunityID with an AND operation shouldn't ever be true.
I had similar problems adding conditions to linked entities. I found that i could do it using the dynamics 2013 sdk, but you would have to see if you could use the 2013 sdk against a 2011 dynamics. Please see Microsoft Dynamics Crm Sdk - Is this query possible?
The basic difference with the 2013 SDK is you can add a condition to the filter but give it an entity name which is for a linked entity. This means you don't actually add the condition to the link entity itself.
I also show in that link how to use the Linq provider to write the query which is another alternative you may want to try.

Cognos 8 SDK: How to get Subgroups of a Group?

I try to get the Subgroup of a Group in the standard Cognos Namespace.
Quering the Contentstore to get ALL groups works fine.
The standard methodes to get "members" of objects return the users or only the "root" group (the group I want the subgroups of). Nothing else....
Am I doing something wrong or is it just "not to be done" ?
I found a way of doing it:
Assuming you have the searchpath for the group you want the subgroups of.
Query the contentstore for it with following PropEnum:
PropEnum[] props = {
PropEnum.defaultName,
PropEnum.searchPath,
PropEnum.members };
As result you get a BaseClass[] object (with only one element though...).
Import com.cognos.developer.schemas.bibus._3.Group <--- this is part of the Cognos SDK libraries and
now you can cast the object[0] to Group.
object.getMembers().getValue()[] is an array of all members INCLUDING groups, roles, accounts.
In java it looks like this (query for the object already done):
Group group = (Group)object[0];
BaseClass obj = null;
for (int i = 0; i < group.getMembers().getValue().length; i++){
obj = group.getMembers().getValue();
System.out.println(obj.getSearchPath().getValue());
}

Query on object id in VQL

I'm currently working with the versant object database (using jvi), and have a case where I need to query the database based on an object id.
The problem is I'm running some performance tests on the database using the pole position framework, and one of the tests in that framework requires me to fetch an object from the database using either an object reference or a low level object id. Thus, I'm not allowed to reference specific fields in the employee object, but must perform the query on the object in its entirety. So, it's not allowed for me to go "select * from Employee e where e.id = 4", I need it to use the entire object.
What I'm trying to achieve is something along the lines of
Employee employee = new Employee("Mr. Pickles");
session.commit();
FundVQLQuery q = new FundVQLQuery(session,
"select * from Employee employee where employee = $1");
q.bind(employee);
q.execute();
However, this throws an EVJ_NOT_A_VALID_KEY_TYPE error. Does anyone know the correct way of doing this?
Sure you figured this out (post was months ago). What you want to do is use the GetObjectId first, to get the VOD Id of the object, then query the DB;
id = session.GetObjectId(employee);
This is how I did the whole roundtrip object → OID → object:
First you get the OID with TransSession.getOidAsLong.
TransSession session = ...;
Employee employee = new Employee("Mr. Pickles");
long oid = TransSession.getOidAsLong(employee);
session.commit();
Once you have the object ID, just grab the object from its Handle.
TransSession session = ...;
Employee employee = (Employee)session.returnHandleFromLong(oid).handleToObject();
No VQL needed.
Usually keys are integers and not strings. You are creating an Employee using just his name, perhaps the correct identifier to use is his employeeId. I need some more information on the table to know for sure.
You can try this,
FundVQLQuery vql = FundVQLQuery (session,
"select selfoid from Employee where name = $1");
vql.bind ("Mr. Pickles");
HandleEnumeration e = vql.execute ();
while ( e.hasmoreHandles() ) {
Handle handle = e.nexthandle();
}
It will return all Employees with the name "Mr. Pickles", Then loop through them.

Resources