Remove the inbuilt filter contact ID from Incident Reports in Customer Portal in Oracle RightNow - oracle

This is about displaying a "Report on Incidents" based on the "Organization" on the Customer Portal. We will be entering the Organization in an input box and then on clicking on "submit". The Incident Report should be displayed only for that Organization.
This is happening but the "Logged In" contacts Id (c_id) is also getting passed as a filter to that Incident Report.
Is it possible to remove the c_id filter that's imposed on the above Incident report? How do I remove this contact ID filter from Incident report?
Someone suggested to use the pre_report_get_data hook and then unset the Contact ID (c_id) filter. But I was not able to figure out how to do that.
Can someone give me a code snippet to remove the c_id filter using pre_report_get_data hook? Or some other solution to this problem.

Copy the report that you want to edit to a new version, then edit the filters of the report as you see fit. You won't be able to edit the default canned reports directly, but with a copy, you can edit it completely.
EDIT
Contact filters are always applied on Customer Portal filters because of the user model on Customer Portal. CP expects that a user on the web is a specific customer and should only have access to contact data that is specific to the particular contact in the user session. This is a security mechanism and is working as intended.
If the goal is to display data from reports that might have contact data related to it, but should be exposed to all contacts, then you should probably write a custom widget that runs a ROQL or Analytics API query directly, but be wary of the potential to expose other customer data if implemented incorrectly.
If you want to use the pre_report_get_data hook, then it's pretty simple to enable the hook in the settings/hooks.php file. Point the hook to the model and method that you want the hook to call. Then, edit the passed array of data to unset c_id from the filters array, as was mentioned in the other post.
$rnHooks['pre_report_get'][] = array(
'class' => 'filter_report',
'function' => 'report_run',
'filepath' => ''
);
That tells the hook engine to call the report_run() method in the filter_report model. These are typically example code files in CP, so you should have most of the work already done to implement that hook.
function report_run($hookData)
{
if($hookData['data']['reportId'] == '100335') //Change the report ID to the report that you need to call
{
unset($hookData['data']['filters']['c_id']); //you'll need to lookup the key of the filter in the report to figure out which one to unset
}
}

Related

Set a field value directly from an asyncValidate result

I have a form where a user enters an Id into a text field, and I then I validate said Id on the server. If the Id does not exist in the system, I display an error. I do this using async validation. If the Id does exist, however, the server will return a record from our database. I want to use those values to auto populate other fields in the form.
How would I accomplish this?
I did some searching and the closest solution I found was this other question on StackOverflow. The thing is, I want to change the value after my asycValidate logic has succeeded. I don't think I can trigger the action creator from inside asyncValidate, and I'm not aware of a way to have asyncValidate trigger a callback from inside the form component.
I was able to get it to work, by following the solutions discussed in the following thread: https://github.com/erikras/redux-form/issues/442

Query to find order products for related accounts in Dynamics CRM

On the Accounts form, I want to be able to show all Order Products for that Account and any related Account. My aim is to give the user an easy way to see what has been bought by a customer with several related offices (Accounts).
Any idea how this can be done?
There is a way to do this with a plugin. The general steps would be:
Ensure the view that is used on the order product subgrid on the Account form is not used anywhere else.
Make a unique change to the view columns or filter criteria that will let you distinguish it from other views. For example, you could add a condition of "createdon contains data", which most likely would not be used anywhere else
Create a pre-RetrieveMultiple plugin on Order Product.
In the plugin, get the query from the input parameters and check for the "createdon contains data" condition. If it does not exist, exit the plugin.
If the condition exists, this is the view you want to update. In the query, find the condition that has accountid.
Use the accountid to retrieve related child and parent accounts.
Update the query with a condition checking if accountid is in the list of all the accountids you retrieved.
The query should now return all the relevant order products and display them on the Account form.
This is a rather involved solution with only the high level steps outlined here.
Here is a link that shows an example of modifying a query in a pre-retrievemultple plugin:
https://hachecrm2011.wordpress.com/2013/07/19/filtering-views-by-intercepting-retrieve-multiple-queries-with-a-plugin/

MS CRM Online Custom View - Need to show specific records in View for specific users (based on team)

I have entity "Work Order" for which I have defined many custom views. Work Orders can have records with statuses as "active ,cancelled, closed, inprogress, submitted" etc. My requirement is - currently logged in user who belongs to a specific team "sales representative" should be able to see all records on view.This can be done easily, but If current logged in user does not belongs to "sales representative" team, she should not be able to see "cancelled" records on view but all other record should be visible to her. How can I achieve this using custom filters if it is possible? Or by code changes?
It is possible to do this with custom code. Without questioning the "why" you'd like to do this (possibly it's sensitive information or something?), you can achieve it using a RetrieveMultiple plugin registered on the pre-operation event. Within this plugin one of the input parameters passed in is called "Query" and will have a QueryExpression. You can simply add a filter to this query in the plugin and the relevant rows will be filtered out. Something like this:
var query = (QueryExpression)context.InputParameters["Query"];
var condition= new ConditionExpression()
{
AttributeName = "statuscode",
Operator = ConditionOperator.NotIn,
Values = { 2, 3 } // Or whatever codes you want to filter!
};
query.Criteria.AddCondition(condition);
To check the current user you can grab the user id from the plugin context and retrieve the necessary info you would like to check.
Doesn't sound like this is possible with advanced find alright. You may be able to achieve it using security roles though. If you could assign cancelled work orders to a specific team, and then organise your security setup so that users who are not sales representatives can't see work orders from that specific team, then it might work. Unfortunately you would have to reassign the cancelled work orders which is not always an option.
Otherwise, you might have to go with a separate view for cancelled work orders, out of the box advanced find should allow you present a blank grid of you are not on the right team. But now obviously you are not presenting a whole view of the work orders.
In general I would go with the security option, and just make it work. Any other option is just a stop-gap. Users can always create custom views, so if you don't lock down access using security roles, the data is still accessible in indirect ways.

How to show records related to upper records too in a subgrid?

How can I build a subgrid that displays related records both of the current record and records above it, and can it contain complex conditions ?
One of my requirements is this:
I want to put a subgrid in Account form showing the related Contacts of the current Account, and also include the Contacts related to Accounts above the current one if a Two Options attribute of the contact is set to Yes.
Specifically, I'm looking at the Company Name on Contact to establish it's related to an Account.
I'm at a loss and start to doubt it's doable.
Not an out of the box solution but if you don’t mind losing the sub grid command bar functionality you can use the following concept that displays a fetchxml inside a sub-grid.
Step 1 - would be to get all related accounts ids using a fetch or odata
Step 2 - construct a fetchxml with OR filter to get all contacts

MS CRM Save + Copy as new (Custom Entity)

I have a custom entity in Microsoft CRM (4.0). The user has to input records however usually they have a batch of 20+ records that are almost the same apart from 2 or 3 fields which need changing. I know I need to write some custom code to enable this functionally. However can anyone recommend any methods to do this.
Ideally there should be a button that will save and create a copy as a new entity.
My Current way of thinking is to pass all the details as part of the URL and use javascript to strip them out on the page load event. Any ideas welcome.
Thanks
Luke
I found the answer here:
http://mscrm4ever.blogspot.com/2008/06/cloning-entity-using-javascript.html
I've used it and it appears to work well.
Since there are numerous fields, but only certain fields values are different, then i am thinking to set the default value to all the fields, so that users just need to alter those values when needed.
In my approach, i will hook a javascript function on load of the form data entry screen and use XmlHttp approach/Ajax approach to hook to the custom web service to pull/retrieve the default values of each fields. Or you can set those values at the javascript function itself, but the drawback of this, it's difficult to customize later. So i will choose the approach to hook to the custom web service and retrieve those value from some application parameter entity.
Your idea of providing a "clone" button is also a great idea, which means that it will duplicate all the attributes of the previous record, into a new record, so that it will save time for data entry person to customize the different value
EDIT
Since you would enter records in batch mode, how about customizing .ASPX screen to enter records. By customizing through .ASPX screen, you can use a tab , so that users can browse through tabs, to customize the value/attribute of each record.
There will be a "save" button as well as "clone" button to clone some common attribute or value.
I would create a custom web service that would accept the entity type and the ID of the record I'm cloning. Your "Save and Clone" button would call the service, and the service would handle the details of retrieving the current record and deciding which fields to set on the new record. The service creates the record, and sends the Guid of the record back to your button, which then opens up the newly created record.
This way, you avoid the messiness of setting/getting values in JavaScript and tying which fields to set/retrieve directly to your OnLoads, as well as avoiding the possibility of query string that's too long.
The service could easily be sufficiently generalized so that all you'd have to do is add your button to any entity, and it would work, assuming you'd set up your service to handle that particular entity.
One possible downside is that since the clone record button would actually create the record, the user would be forced to delete the cloned record if they decided they didn't want to clone the record after all.

Resources