Following a Microsoft hands-on lab for Dynamics CRM 2011, I am attempting to add a custom view to a form that responds 'onchange' to a particular property. Here is my function to add the custom view:
function HandleOnChangeDVMInformationLookup()
{
var locAttr = Xrm.Page.data.entity.attributes.get("new_referringdvm");
if (locAttr.getValue() != null)
{
var dvmId = locAttr.getValue()[0].id;
var viewDisplayName = "DVM Information";
var viewIsDefault = true;
var fetchXml = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="dvminformation"><attribute name="dvminformation_id"/><attribute name="dvminformation_name"/><attribute name="new_firstname"/><attribute name="new_lastname"/><filter type="and"><condition attribute="id" operator="eq" value="' +dvmId +'"/></filter></entity></fetch>';
var layoutXml = '<grid name="resultset" object="10001" jump="dvminformation_name" select="1" icon="1" preview="1"><row name="result" id="dvminformation_id"><cell name="dvminformation_name" width="300" /><cell name="new_firstname" width="125"/></row></grid>';
var control = Xrm.Page.ui.controls.get("new_dvm_information");
control.addCustomView("62e0ee43-ad05-407e-9b0b-bf1f821c710e", "dvminformation", viewDisplayName, fetchXml, layoutXml, viewIsDefault );
}
}
Upon changing the selected 'dvm' in the form and triggering this function I receive the following error:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The entity with a name = 'dvminformation' was not found in the MetadataCache.Detail:
-2147217150
The entity with a name = 'dvminformation' was not found in the MetadataCache.
2013-06-10T22:01:49.4392114Z
Is 'dvminformation' not the entity name I just defined in the XML? Am I missing a step?
Thanks.
It's unlikely that dvminformation is a real entity name. Are you sure there is an entity that exists with that name?
Open the solution and look for the entity, then check its schema name.
If its a custom entity they usually have the format of prefix_name, e.g. new_timeline, new_alert, in your case it might just be dvm_information. If dvm is your solution prefix.
Only system entity have a name without an underscore, e.g. contact, account, incident and dvminformation doesn't look like a system entity to me.
I had the same error message with the customerAddress entity.
Turns out I referenced the entity as "customerAddress" (note the camel case).
But CRM wants logical names of entities and attributes in all lower case. So "customeraddress" did work.
Check if you are connecting to correct org (web.config?)
See
Related
I'm a novice in MVC, Below is my code
I am unable to read the value of an ID and use that in an decision statement, I am getting "The name "Text" does not exist in current context", I need to work on the if statement based on the value I get from my document.getElementById
#{
var grid = new WebGrid(Model.Abc, canPage: true, canSort: true, rowsPerPage: 50);
}
#{
var gridColumnsNew = new List<WebGridColumn>();
gridColumnsNew.Add(grid.Column("Details", header: "Id"));
<text>
var obj = document.getElementById("NextAction").value;
</text>
if (#text.obj == "Start")
{
gridColumnsNew.Add(grid.Column("Temp"));
}
}
Try using
document.getElementsByName("NextAction").value;
I have seen in my case that Blazor changes Id to name.
Note: I am using DevexpressBlazor
Did you checked if you are able to see on the html generated that ID?
If yes, Did you have any JS error before?
Looks like the ID not was generated or the place where you are run the getElementById don't have visibility to your specific code.
You are mixing razor syntax and javascript. The line var obj = document.getElementById("NextAction").value; is javascript and should go inside <script> tag. You can't call javascript functions from razor code.
Solution:
Assuming you have a controller named GridController.cs and a view named Grid.cshtml. Inside your controller add a new HttpPost action:
[HttpPost]
public IActionResult NextAction(string nextAction)
{
ViewData["NextAction"] = nextAction;
return View("Grid");
}
Inside the view add a form that posts the nextAction value to the controller:
<form asp-action="NextAction" asp-controller="Grid">
<input type="hidden" value="Start" name="nextAction" />
<button type="submit">Start</button>
</form>
The controller added the NextAction value in the ViewData dictionary so now the view can access it:
#{
var gridColumnsNew = new List<WebGridColumn>();
gridColumnsNew.Add(grid.Column("Details", header: "Id"));
if (ViewData["NextAction"] == "Start")
{
gridColumnsNew.Add(grid.Column("Temp"));
}
}
You are getting that error because you are using #text.obj. In Razor, once you attached # before any identifier, it considers it a C# or VB variable.
Since we don't have your entire page, you may need to clarify where the source of the NextAction. It will be helpful. See a sample of something similar.
#if(item.Ward == "start")
{
gridColumnsNew.Add(grid.Column("Temp"));
}
The item is from the model I am iterating to form the grid.
First of all sorry for my bad english i am french !
So i have a little problem. I use the django built-in class ChoiceField in my form :
class LogForm(forms.Form):
FormData = (('1', 'Code',), ('2', 'Normal',), ('3', 'Hexa',))
choixFormData = forms.ChoiceField(label=' Forme des donnees ', choices=FormData)
liaison = (('1', 'RS232_1_Port1',), ('2', 'RS232_1_Port2',), ('3', 'RS232_1_Port3',), ('4', 'RS232_1_Port4',),
('5', 'RS422_1_Port1',), ('6', 'RS422_1_Port2',), ('7', 'RS422_1_Port3',), ('8', 'RS422_1_Port4',),
('9', 'RS422_2_Port1',), ('10', 'RS422_2_Port2',), ('11', 'RS422_2_Port3',), ('12', 'RS422_2_Port4',),
('13', 'VoieNumAna',), ('14', 'CAN1',), ('15', '1553',))
choixLiaison = forms.ChoiceField(label='Liaison', choices=liaison)
Data = forms.CharField(required=False, label=' Data ', max_length=100, widget=forms.Textarea)
And i also use the Django Channels in order to implement websockets in my app.
The thing is, i want to be able to render the form thanks to the view ( this is working fine ) and then i want to get the value of the selected choice ( once the the form is rendered ) using javascript.
I tried this :
document.querySelector('#id_Start').onclick = function(e) {
const messageInputDom = document.querySelector('#id_choixLiaison');
const message = messageInputDom.value;
chatSocket.send(JSON.stringify({
'message': message
}));
messageInputDom.value = '';
}
I am very new to javascript and i dont understand the reason why this is not working.
I want to be able to get the value of the selected choice field in a string.
Do not hesitate to tell me if the question is badly asked or if you need more details.
Thank you !
Since I want to get the companyTitle when a user selects something from the dropdown menu. I have defined it like this data-description="${companyTitle}" as shown in the code below of the success function of my Ajax call.
success : function(data) {
$.each(data.personnelData.reverse(), function (i) {
let companyId = data.personnelData[i].companyId;
let companyTitle = data.personnelData[i].title;
let dateOfCreation = moment(data.personnelData[i].createDate).format('MM/DD/YYYY');
$("#myList").append(`<option data-description="${companyTitle}" value="${companyId}">${companyTitle}|${dateOfCreation}</option>`);
});
},
When I tested it like this in my javascript code:
$("select#myList").change(function(){
console.log("Testing companyTitle");
console.log($('#myList :selected').data('description'));
})
I only saw the following in the console log - Company Set for
And I believe it is because of the following:
When I inspected the option tag in the browser, It showed me the following entry:
<option data-description="Company Set for " abc="" pxy="" psqrty#12:20:49"="" (4="" companies="" on="" 09="" 22="" 2020="" 01:20:53="" pm)"="" value="12345">Company Set for "Abc Pxy Psqrty#12:20:49" (4 companies on 09/22/2020 01:20:53 PM)|09/22/2020</option>
How can I fix this so that inside $("select#myList").change(function(){ I can retrieve only the part inside the double quotes (i.e. Abc Pxy Psqrty#12:20:49) of the following companyTitle:
Company Set for "Abc Pxy Psqrty#12:20:49" (4 companies on 09/22/2020 01:20:53 PM)
If rather than building your option using string concatenation, you build it using jQuery's object model the description data does not get garbled because of the quotes:
const companyTitle = "Company Set for \"Abc Pxy Psqrty#12:20:49\" (4 companies on 09/22/2020 01:20:53 PM)",
companyId = 1,
dateOfCreation = "01/01/2020";
const $option = $('<option />')
.val(companyId)
.text(`${companyTitle}|${dateOfCreation}`)
.data('description',companyTitle);
$('#myList').append($option);
$('#myList').on('change', function(){
console.log($(":selected", this).data('description'));
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="myList">
<option>Select</option>
</select>
If you then want to extract just the bit in quotes that should be fairly straightforward - use regex or string manipulation. There are plenty of examples of extracting the value between quotes.
When data in the data.personnelData[i].title always similar and has only one pair of double quotes you can split that string like:
var companyTitle = "Company Set for \"Abc Pxy Psqrty#12:20:49\" (4 companies on 09/22/2020 01:20:53 PM)";
var companyTitleDescription = companyTitle.indexOf('"') > -1 ? companyTitle.split("\"")[1] : companyTitle;
console.log(companyTitleDescription);
and assign that to your data-description attribute.
I'm trying to change the display format on the DatePicker/TimePicker used by the sap.m.P13nItem when the selected column type is date/time.
I have tried changing the aggregation P13nItem from the P13nFilterPanel in order to include the property formatSettings, but it didn't work.
Here is a sample of my XML view code.
<P13nFilterPanel id="filterPanel" visible="true" type="filter" containerQuery="true" items="{
path: 'SchedulingFilter>/ColumnCollectionFilter'
}" filterItems="{
path: 'SchedulingFilter>/FilterItems'
}">
<P13nItem columnKey="{SchedulingFilter>columnKey}" text="{SchedulingFilter>label}" type="{SchedulingFilter>type}" maxLength="{SchedulingFilter>maxLength}" formatSettings="{SchedulingFilter>formatSettings>" />
<filterItems>
<P13nFilterItem columnKey="{SchedulingFilter>keyField}" operation="{SchedulingFilter>operation}" value1="{SchedulingFilter>value1}" value2="{SchedulingFilter>value2}" exclude="{SchedulingFilter>exclude}" />
</filterItems>
</P13nFilterPanel>
Here is an extract of how I'm filling the bound data.
$.each(columnsKeys, function (i, item) {
const columnData = {};
const columnDescriptionItem = columnDescription[item];
columnData.columnKey = item;
columnData.text = columnDescriptionItem.label;
columnData.type = columnDescriptionItem.type;
columnData.formatSettings = {
pattern: 'yyyy/MM/dd',
UTC: false
};
columnData.maxLength = columnDescriptionItem.maxLength;
columnData.visible = columnDescriptionItem.visible;
columnData.index = columnDescriptionItem.index;
columnData.isEditable = columnDescriptionItem.isEditable;
columnData.isFilter = columnDescriptionItem.isFilter;
columnData.isSorter = columnDescriptionItem.isSorter;
columnsData.push(columnData);
});
The default behavior of the control displays the time/date fields as:
https://ibb.co/JcJJZhJ.
Edit: I discovered that the default behavior is based on the user's locale. I'm not considering the user's locale to change the display format on the others parts of my application.
I want to achieve, for example, the display formats "yyyy/MM/dd" and "hh:mm:ss" on these fields.
I had to extend the P13nConditionPanel (this one is responsible for the time/date components instantiation) and the P13nFilterPanel (it creates the P13nConditionPanel) on version 1.44.6 of SAPUI5 in order to solve this problem. I only had to add the necessary parameters to the DatePicker and TimePicker constructors (as shown below).
case "date":
oConditionGrid.oFormatter = sap.ui.core.format.DateFormat.getDateInstance();
params.displayFormat = DateFormatter.displayFormat();
oControl = new sap.m.DatePicker(params);
break;
case "time":
oConditionGrid.oFormatter = sap.ui.core.format.DateFormat.getTimeInstance();
params.displayFormat = TimeFormatter.getDisplayFormat();
oControl = new sap.m.TimePicker(params);
I posted my customized extended components code on pastebin:
Customized P13nConditionPanel
Customized P13nFilterPanel
I will later open an enhancement request on openui5 Github.
I am creating admin panel in website and I am using firebase as a database in backend.I am able to display listing but when I click on the particular listing there status should change from 'pending' to 'accept' but it doesnt.I dont know where I did mistake.Please give suggestion and I attach js file and database screenshot
pl.js
var firebaseheadingRef = firebase.database().ref().child("user");
firebaseheadingRef.on('child_added',datasnapshot=>{
var title= datasnapshot.child("listing").child("title").val();
var userid= datasnapshot.child("username").val();
var type= datasnapshot.child("listing").child("title").val();
var publisheddate= datasnapshot.child("listing").child("publish").val();
var expirydate= datasnapshot.child("listing").child("expire").val();
$("#tablebody").append("<tr><td>"+title+"</td><td>"+userid+"</td><td>"+type+"</td><td>"+publisheddate+"</td><td><button type=button id=accept onclick=accept()>Accept</button><button type=button>Reject</button></td></tr>");
});
function accept()
{
firebaseheadingRef.on('child_changed',datasnapshot=>{
datasnapshot.child("listing").child("status").update({"status":"accept"});
setCommentValues(postElement, data.key, data.val().text, data.val().author);
});
}
database
listing display picture where I click on accept button then update of status should done
There are two places where you need to change your code:
First, in the code that generates the table, you have to pass the id of the node to the function call, as follows. You get the node id with the key property of the DataSnapshot.
.....
$("#tablebody").append("<tr><td>"+title+"</td><td>"+userid+"</td><td>"+type+"</td><td>"+publisheddate+"</td><td><button type=button id=accept onclick=accept('" + datasnapshot.key + "')>Accept</button><button type=button>Reject</button></td></tr>");
...
And secondly you have to write your accept() function in such a way it updates the database value, with the set() method. Like the following
function accept(userId) {
var nodeRef = firebase.database().ref("/user/" + userId + "/listing/status");
return nodeRef.set('accept');
}