I used a piece of code that retrieves a field link for a specified content type and sets the field to either required or not required. This works fine but when I try to do the same for a field that has spaces in the name, the code throws an error.
SPField col = //some column retrieved from a list
SPContentType ct = col.ParentList.ContentTypes["MyContentTypeName"] //gets the content type
SPFieldLink fieldLink = ct.FieldLinks["MyFieldname"]; // gets the fieldLink
ct.Update();
It works if MyFieldName is a string like "Hobbies" or "Amount", but fails if it's a string like "Full Name".
Is there a workaround?
You are probably using the field display name instead of the field internal name
Have you tried:
"Full_x0020_Name" ?
Related
I am trying to run a SharePoint api query to match against a column with a specific value.
The column value contains a space which is resulting in the query not working as expected. Returning anything with 'value' in the column rather than just items where the column = 'value 2'.
My current url looks like where $listId is a list guid
https://mysite.sharepoint.com/_api/search/query?querytext='(customColumn:value 2)+AND+(ListID:$listId)'&selectproperties='Name,Title,Description,Author,LastModifiedTime,Path'
What is the syntax for
(customColumn:value 2)
That allows me to only return results where customColumn = "value 2"?
Try to encode the endpoint as
_api/search/query?querytext='customColumn:value%202'
My test Sample:
/_api/search/query?querytext='Title:Developer%20-%20Wiki1 Author:Lee'
i need to to add a text calculated field in TestTrack, so the field always add itself and then anoter field.
so the field will always contain the previous entry and the new one.
how can i do it ?, without the testtrack claiming its a recursive formula
the only way to dit is to do a count of the event (adding data to the field)
and than run a for each of the ocurrnces with a concatenate of the data with the string itself (old value).
here is the example that works for me :
var TicketCount=Item.Events.count("update ticket");
var ticketsStr ='';
for(ticketIndex = 0;ticketIndex < TicketCount;ticketIndex++)
{
ticketsStr = ticketsStr + Item.Events.at(ticketIndex,"update ticket").fieldValue("Customer Name");
if(ticketIndex < TicketCount-1)
ticketsStr = ticketsStr + ",";
}
result = ticketsStr;
You are correct that a TestTrack calculated field cannot reference itself in the formula. Even if it could reference itself, consider the following formula for "update ticket":
Item.fieldValue("update ticket")+Item.fieldValue("Type")
In this scenario, the Type value would always be appended but there would be no check to see if the Type value is already in the list. Every time an item is edited the "update ticket" field value would be recalculated and the Type value would be appended again whether it has changed or not.
The solution proposed by Tal solves this problem by looping through the other fields and re-building the value. Additionally if a Customer Name value is modified or deleted, the field value will be correctly calculated.
We are populating a subregion of a page with an Iframe (call to another page) with data for a questionnaire.
We have PAGE ITEM variables (:P37_... populated by query) that contain table values for P37_QUESTION_DESCRIPTION and P37_RESPONSE_TYPE.
The sub page used in the region (:P28_...) assigns report attributes for each column... where We populated the question text in the P28_QUESTION_DESC and a Y/N Select List defined list of values in the P28_RESPONSE_DESC_DISPLAY column. This works fine.
Now, the P37_RESPONSE_TYPE can more than just this Y/N Select List. It could be TEXTAREA, PICKLIST, DATE...
How can we define the :P28_RESPONSE_DESC_DISPLAY column dynamically to be any number of user input field types (based on the value in :P37_REPSONSE_TYPE?)
This was solved by using a non-tabular form report generated by query using apex.item functions. But is has left me with another problem. Here's the query:
select
apex_item.hidden(31,CASE_QUEST_DTL_ID) CASE_QUEST_DTL_ID,
apex_item.hidden(32,CASE_MGMT_BASE_ID) CASE_MGMT_BASE_ID,
apex_item.display_and_save(33,to_number(question_seq_no)) QUESTION_SEQ_NO,
apex_item.display_and_save(34,question_desc) QUESTION_DESC,
case when response_type = 'PICKLIST-YESNO' then apex_item.select_list_from_lov(35,response_desc,'YES_NO_SELECTLIST',NULL,'NO')
when response_type = 'TEXTFIELD' then apex_item.text(35,response_desc)
when response_type = 'TEXTAREA' then apex_item.textarea(35,response_desc,5,40)
when response_type = 'DATEPICKER' then APEX_ITEM.DATE_POPUP2(35,to_date(response_desc,'dd-mon-yyyy'),'dd-mon-yyyy')
end RESPONSE_DESC
from V_CASE_QUEST_LINK
where question_set_code like 'COB_Q%'
and case_mgmt_base_id = :P37_CASE_MGMT_BASE_ID
My problem is now grouping the questions by question_set_code. Because GROUP BY is evaluated after the select, it cannot simply be tacked on to the end of the query. I'm not sure that using a nested select will work here because of the apex.item calls. Anyone have a suggestion on how I can group these questions by the column?
for the following method
Uri uri = ContentUris.withAppendedId((MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id);
i have read many examples but none of the examples tell me what to do with "id" part of the perameter, i don't want to assign which row because that will change depending of what row the specific image is stored in. so i can't hard code "id". how to deal with this? and can i leave the id as null?
edit
i just found this a few minutes ago from a website, http://www.grokkingandroid.com/android-tutorial-using-content-providers/
values.clear();
values.put(Words.WORD, "Zaphod");
Uri uri = ContentUris.withAppendedId(Words.CONTENT_URI, id);
long noUpdated = resolver.update(uri, values, null, null)
here is the quote from the author, "Since I changed only one record, a URI with an appended ID is sufficient. But if you want to update multiple values, you should use the normal URI and a selection clause."
so he says to use a "normal URI and selection clause" so how do i do that?
this is my selection statement:
String selection = MediaStore.Images.Media.DATA + "='" + filename +"'";
where "filename" is a string variable that varies depending on the image selected, for example, in this case /mnt/sdcard/pic09.png
I'm not sure if I understood your question, but regarding the part when you ask how do you do the normal URI and selection clause, the "trick" is that using content providers you dont put the whole selection in one argument as:
String selection = MediaStore.Images.Media.DATA + "='" + filename +"'";
but instead, you introduce the selection type, selection arguments through different input variables. So for example, the
update where MediaStore.Images.Media.DATA equals filename
becomes:
update (uri, contentValues, String selection, String[] selectionArgs)
where uri points to the table (not the row)
content values point to a ContentValues object with your new values
selection must contain the fields to be compared + comparrisson type + question mark, as
MediaStore.Images.Media.DATA + " = ?";
And selection arguments is an array with all the strings replacing question marks on your selection string, so in your case just
{filename}
In the below C++ code, i am updating a field of emp table based on the search value. But this code is not working properly. I am getting output as aborted.
void UpdateData(string field_name,string updated_value,string search_value)
{
stmt->createStatement("UPDATE emp SET :1=:2 where search=:3");
stmt->setString(1,field_name);
stmt->setString(2,updated_value);
stmt->setString(3,search_value);
stmt->executeUpdate();
}
In my program user will select which field they have to update and the selected field name is passed into function as field_name parameter. updated_value is the new value entered by the user and search_value is the search key to find the appropriate record.
If i do like
stmt->createStatement("UPDATE emp SET field_name=:2 where search=:3");
its working..
But the problem is, the field name will change according to user selection. How i can overcome this problem. Is there any other way ?
You can't set the name of the field with the statement->setString() method; only the values of the variables can be bound like that.
I know of only two solutions to achieve this (both aren't particularly nice):
Dynamically create the statement string
string statement ="UPDATE emp SET " + fieldname + "=:1 where search=:2";
Prepare individual statements, each affecting one field and choose at runtime
const string STATEMENT_FIELD_CITY = "UPDATE emp SET CITY=:1 where search=:2";
const string STATEMENT_FIELD_LAND = "UPDATE emp SET LAND=:1 where search=:2";